diff --git a/packages/url-manager/README.md b/packages/url-manager/README.md index 1fd3d73..0fc339d 100644 --- a/packages/url-manager/README.md +++ b/packages/url-manager/README.md @@ -1,6 +1,6 @@ # URL Manager -simple to use yet powerful Urls parser and formatter +A simple to use yet complete Urls parser and serializer ## Usage @@ -23,9 +23,7 @@ const URLManager = require('@dzeio/url-manager').default ```typescript // Create a new instance -const url = new URLManager() // you can have an URL, URLSearchParams Objects or a string as parameter -// or -const url = URLManager.fromLocation() // Browser only return a new instance from the current location +const url = new URLManager(/* Optionnal */ baseUrl) // you can have an URL, URLSearchParams Objects or a string as parameter ``` - manipulate the url @@ -33,6 +31,7 @@ const url = URLManager.fromLocation() // Browser only return a new instance from ```typescript // Get set delete query +url.query() // get an object containing everything url.query("sort") // get url.query("sort", 'value') // set url.query("sort", null) // delete @@ -73,19 +72,10 @@ url.hash('i-am-a-hash') // set - format it back to a string ```typescript - -url.toString() -`${url}` +url.toString() // => the serialized URL // NOTE: if the path contains elements like [param] // you can replace them in the toString function like this +// /pouet/[param] => /pouet/test url.toString({param: 'test'}) ``` - -- you have also two "util" functions (Available only in the browser) - -```typescript -url.reload() // reload the current page -url.go() // go to the url -url.go(false) // show the next url in the browser without changing the content of the document -``` diff --git a/packages/url-manager/package.json b/packages/url-manager/package.json index 3d288f5..99407d8 100644 --- a/packages/url-manager/package.json +++ b/packages/url-manager/package.json @@ -1,13 +1,25 @@ { "name": "@dzeio/url-manager", "version": "1.0.5", - "description": "Manage URL", - "repository": "https://github.com/dzeiocom/libs.git", + "description": "A simple to use yet complete Urls parser and serializer", + "repository": { + "type": "git", + "url": "https://github.com/dzeiocom/libs.git", + "directory": "packages/url-manager" + }, "homepage": "https://github.com/dzeiocom/libs/tree/master/packages/url-manager#readme", "author": "Aviortheking", "license": "MIT", "main": "./dist/URLManager.js", "types": "./dist/URLManager.d.ts", + "keywords": [ + "url", + "url-manager", + "url serializer", + "url parser", + "parser", + "serializer" + ], "devDependencies": { "@types/chai": "^4.2.12", "@types/jest": "^26.0.10", diff --git a/packages/url-manager/src/URLManager.ts b/packages/url-manager/src/URLManager.ts index b4e8b3a..9888e44 100644 --- a/packages/url-manager/src/URLManager.ts +++ b/packages/url-manager/src/URLManager.ts @@ -61,7 +61,7 @@ export default class URLManager { /** * set/delete a key to a value in the query string * @param key the key to set/delete - * @param value the value to set or null to delete it + * @param value the value to set or `null` to delete it */ public query(key: string, value: string | Array | null): this