Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/raut-andrey/urls-tool
Tool for simple work with url, params, hash
https://github.com/raut-andrey/urls-tool
Last synced: 16 days ago
JSON representation
Tool for simple work with url, params, hash
- Host: GitHub
- URL: https://github.com/raut-andrey/urls-tool
- Owner: raut-andrey
- License: isc
- Created: 2019-06-20T14:15:05.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-07-11T11:56:39.000Z (over 5 years ago)
- Last Synced: 2024-09-26T08:21:32.650Z (about 2 months ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 10
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# urls-tool
A little script that will help you work with the url `path` / `params` / `hash` without reloading the page.## Installing
Using npm:
```
$ npm install urls-tool
```Using yarn:
```
$ yarn add urls-tool
```## Example
#### Easily get or change url pathname.
```
import Url from "urls-tool";const { pathname } = Url;
// Variable `pathname` will be have the pathname value in string.Url.pathname = "your path name";
// Pathname will be changed.```
#### Effortlessly get or set (just one or all at once) params
```
import Url from "urls-tool";const { params } = Url;
// Variable `params` will be have the object with all params in shape `{ "paramsName": "paramsValue" }`.const {
array, // Array of all params. [{ name: "paramsName", value: "paramsValue" }]
object, // The same object as in the previous method
string // String of params without "?".
} = Url.getParams();Url.params = ["paramsName", "paramsValue"];
// Use to set only one params item. Also it will be removed in the absence or FALSE value of "paramsValue".Url.params = { "paramsName": "paramsValue" };
// Use to set all params at once. All params will be cleared in case of an empty object.
```
#### No problem get or set the hash
```
import Url from "urls-tool";const { hash } = Url;
// Variable `hash` will be have the hash value in string without "#".Url.pathname = "your path name";
// Hash will be changed. And you don't need to add "#"
```
## License
ISC