1.0.4 • Published 7 years ago

get-link v1.0.4

Weekly downloads
16
License
MIT
Repository
github
Last release
7 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

7 years ago

1.0.3

7 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.0.26

8 years ago

0.0.25

8 years ago

0.0.24

8 years ago

0.0.22

9 years ago

0.0.21

9 years ago

0.0.2

9 years ago

0.0.11

9 years ago

0.0.1

9 years ago