https://github.com/hungtcs/url-component-join
normalize and join url components
https://github.com/hungtcs/url-component-join
Last synced: over 1 year ago
JSON representation
normalize and join url components
- Host: GitHub
- URL: https://github.com/hungtcs/url-component-join
- Owner: hungtcs
- License: unlicense
- Created: 2022-09-20T02:16:40.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-11-17T09:11:09.000Z (over 3 years ago)
- Last Synced: 2025-01-26T04:41:47.777Z (over 1 year ago)
- Language: TypeScript
- Homepage:
- Size: 57.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# URL Component Join
normalize and join url components
## Installation
```shell
npm install --save url-component-join
```
## Functions
### `normalize(path: string): string`
Normalizes the given path, remove redundant `/` and resolving `..` and `.` segments.
```ts
import { normalize } from 'url-component-join';
normalize('//a/a/..//b.c');
// /a/b.c
```
### `join(...paths: Array): string`
Normalize and join several segments into one path
```ts
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`