From 583081542de188a160296e4b2f65c58df836152c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E5=9F=B9=E5=A0=AF?= Date: Tue, 21 Nov 2017 09:15:05 +0800 Subject: [PATCH] Add delete query param sample and test --- README.md | 6 ++++++ package.json | 5 ++++- src/test.ts | 10 ++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6047835..bb5f9d3 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,12 @@ builder.fragment = 'hash'; // Log builder result, result: 'https://www.google.com/search?q=newKeyword#hash' console.log(builder.toString()); +// Delete Query Param +delete builder.query.q; + +// Log builder result, result: 'https://www.google.com/search#hash' +console.log(builder.toString()); + // Update input URI Query const updatedURI = UriBuilder.updateQuery(testURI, { q: 'test', diff --git a/package.json b/package.json index d141689..8fc6e45 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,10 @@ "build": "gulp build", "test": "npm run build && node dist/test.js" }, - "keywords": ["URI", "URL"], + "keywords": [ + "URI", + "URL" + ], "homepage": "https://github.com/XuPeiYao/uriBuilder", "repository": { "type": "git", diff --git a/src/test.ts b/src/test.ts index f444c92..955aee1 100644 --- a/src/test.ts +++ b/src/test.ts @@ -190,3 +190,13 @@ emptyBuilder.query.action = 'back'; console.assert( emptyBuilder.toString() === 'http://guest@example/home/index?action=back#top' ); +emptyBuilder.toString(); + +hr(); +console.info('Delete Query Param Test'); + +delete emptyBuilder.query.action; +console.assert( + emptyBuilder.toString() === 'http://guest@example/home/index#top' +); +console.log(emptyBuilder.toString());