mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-12 12:10:44 +08:00
Add definitions for hasSearch()/hasQuery();
This commit is contained in:
@@ -60,3 +60,34 @@ URI('http://user:pass@example.org:80/foo/bar.html?foo=bar&bar=baz#frag').equals(
|
||||
h: "frag"
|
||||
})
|
||||
);
|
||||
|
||||
/*
|
||||
Tests for hasSearch(), hasQuery()
|
||||
From: http://medialize.github.io/URI.js/docs.html#search-has
|
||||
*/
|
||||
|
||||
uri = URI("?string=bar&list=one&list=two&number=123&null&empty=");
|
||||
|
||||
uri.hasQuery("string") === true;
|
||||
uri.hasSearch("nono") === false;
|
||||
|
||||
uri.hasQuery("string", true) === true;
|
||||
uri.hasSearch("string", false) === false;
|
||||
|
||||
uri.hasQuery("string", "bar") === true;
|
||||
uri.hasSearch("number", 123) === true;
|
||||
|
||||
uri.hasQuery("list", "two", true) === true;
|
||||
uri.hasSearch("list", ["two"], true) === true;
|
||||
uri.hasQuery("list", "three", true) === false;
|
||||
uri.hasSearch("list", ["two", "three"], true) === false;
|
||||
uri.hasQuery("list", /ne$/, true) === true;
|
||||
|
||||
uri.hasQuery("string", /ar$/) === true;
|
||||
|
||||
uri.hasQuery(/^str/) === true;
|
||||
uri.hasQuery(/^li/, "two") === true;
|
||||
|
||||
uri.hasQuery("string", (value : string, name : string, data : string) => {
|
||||
return true;
|
||||
}) === true;
|
||||
|
||||
Reference in New Issue
Block a user