add type for removeSearch(name, value) (#18451)

This commit is contained in:
Ian Lin
2017-07-27 14:31:46 -07:00
committed by Andy
parent 7cbc0981cd
commit f55037f738
2 changed files with 18 additions and 0 deletions

View File

@@ -89,8 +89,10 @@ declare namespace uri {
relativeTo(path: string): URI;
removeQuery(qry: string): URI;
removeQuery(qry: Object): URI;
removeQuery(name: string, value: string): URI;
removeSearch(qry: string): URI;
removeSearch(qry: Object): URI;
removeSearch(name: string, value: string): URI;
resource(): string;
resource(resource: string): URI;

View File

@@ -95,3 +95,19 @@ uri.hasQuery(/^li/, "two") === true;
uri.hasQuery("string", (value : string, name : string, data : string) => {
return true;
}) === true;
/*
Tests for removeSearch()
From: https://medialize.github.io/URI.js/docs.html#search-remove
*/
var uri = new URI("?hello=world&hello=mars&foo=bar");
uri.removeSearch("hello");
uri.search(true) === "?foo=bar";
uri.search("?hello=world&hello=mars&foo=bar");
uri.removeSearch("hello", "world");
uri.search(true) === "?hello=mars&foo=bar"
uri.search("?hello=world&hello=mars&foo=bar&mine=true");
uri.removeSearch(["hello", "foo"]);
uri.search(true) === "?mine=true"