mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-01 07:40:10 +00: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;
|
||||
|
||||
2
urijs/URIjs.d.ts
vendored
2
urijs/URIjs.d.ts
vendored
@@ -105,6 +105,8 @@ declare namespace uri {
|
||||
setQuery(qry: Object): URI;
|
||||
setSearch(key: string, value: string): URI;
|
||||
setSearch(qry: Object): URI;
|
||||
hasQuery(name: string | any, value?: string | number | boolean | Function | Array<string> | Array<number> | Array<boolean> | RegExp, withinArray?: boolean): boolean;
|
||||
hasSearch(name: string | any, value?: string | number | boolean | Function | Array<string> | Array<number> | Array<boolean> | RegExp, withinArray?: boolean): boolean;
|
||||
subdomain(): string;
|
||||
subdomain(subdomain: string): URI;
|
||||
suffix(): string;
|
||||
|
||||
Reference in New Issue
Block a user