1.0.4 • Published 6 years ago

get-link v1.0.4

Weekly downloads
16
License
MIT
Repository
github
Last release
6 years ago

Greenkeeper badge Build Status License npm version npm downloads

Returns an absolute URL relative to another URL. Not vulnerable to Denial-of-Service attacks.

Installation

$ npm install get-link

Usage

getLink(base: string, link:string): string|false

import getLink from "get-link";

getLink("http://example.com", "/foo/bar");
// => http://example.com/foo/bar

getLink("http://example.com", "/foo.php");
// => http://example.com/foo.php

getLink("http://example.com", "http://example.com/foo.html");
// => http://example.com/foo.html

getLink("http://example.com/some/deep/path", "../../styles");
// => http://example.com/some/styles

getLink("http://example.com", "#dynamic-website");
// => http://example.com

getLink("http://example.com", "javascript:void(0)");
// => http://example.com

getLink("http://example.com", "mailto:email@example.com");
// => http://example.com

getLink("http://example.com", "http://domain.com");
// => false

Tests

$ npm test
1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.0.26

7 years ago

0.0.25

7 years ago

0.0.24

7 years ago

0.0.22

8 years ago

0.0.21

8 years ago

0.0.2

8 years ago

0.0.11

8 years ago

0.0.1

8 years ago