npm.io
0.0.5 • Published 3 years ago

url-component-join

Licence
UNLICENSED
Version
0.0.5
Deps
0
Size
26 kB
Vulns
0
Weekly
0

URL Component Join

normalize and join url components

Installation

npm install --save url-component-join

Functions

normalize(path: string): string

Normalizes the given path, remove redundant / and resolving .. and . segments.

import { normalize } from 'url-component-join';

normalize('//a/a/..//b.c');
// /a/b.c
join(...paths: Array<string>): string

Normalize and join several segments into one path

import { join } from 'url-component-join';

join('//a/a/', '..', '//b.c');
// /a/b.c

join('http://127.0.0.1:8080/a//b', '//c///d')
// http://127.0.0.1:8080/a/b/c/d

join('http://127.0.0.1:8080/a//b', 'http://127.0.0.1:8080//c///d')
// http://127.0.0.1:8080/a/b/c/d
basename(path: string): string
dirname(path: string): string
relative(from: string, to: string): string