url-joiner
v1.1.3
Published
Join url, parse and merge url parts
Downloads
21
Readme
url-joiner
Handy utils for merging and parsing url
Installation
npm i url-joiner --save
or
yarn add url-joiner
Usage
getUrlParts(url)
import { getUrlParts } from "url-joiner";
getUrlParts("https://example?name=ken");
// ['https://example', 'name=ken']
joinUrl(url, search)
import { joinUrl } from "url-joiner";
joinUrl("https://domain.name", "name=ken");
// 'https://domain.name?name=ken'
joinPath(url, ...paths)
import { joinPath } from "url-joiner";
joinPath("https://domain.name", "users", "id", "preview");
// 'https://domain.name/users/id/preview'
parseSearch(search)
import { parseSearch } from "url-joiner";
parseSearch("name=james&surname=willis");
// {
// name: 'james',
// surname: 'willis',
// }
mergeSearch(params, search)
import { mergeSearch } from "url-joiner";
mergeSearch(
{
name: "ken",
age: "21"
},
"name=james&surname=willis"
);
// 'name=ken&surname=willis&age=21'