object urlMod
- Alphabetic
- By Inheritance
- urlMod
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- class URLSearchParams extends Object with StObject with Iterable[Tuple2[String, String]]
The
URLSearchParams
API provides read and write access to the query of aURL
.The
URLSearchParams
API provides read and write access to the query of aURL
. TheURLSearchParams
class can also be used standalone with one of the four following constructors. TheURLSearchParams
class is also available on the global object.The WHATWG
URLSearchParams
interface and thequerystring
module have similar purpose, but the purpose of thequerystring
module is more general, as it allows the customization of delimiter characters (&
and=
). On the other hand, this API is designed purely for URL query strings.js const myURL = new URL('https://example.org/?abc=123'); console.log(myURL.searchParams.get('abc')); // Prints 123
myURL.searchParams.append('abc', 'xyz'); console.log(myURL.href); // Prints https://example.org/?abc=123&abc=xyz
myURL.searchParams.delete('abc'); myURL.searchParams.set('a', 'b'); console.log(myURL.href); // Prints https://example.org/?a=b
const newSearchParams = new URLSearchParams(myURL.searchParams); // The above is equivalent to // const newSearchParams = new URLSearchParams(myURL.search);
newSearchParams.append('a', 'c'); console.log(myURL.href); // Prints https://example.org/?a=b console.log(newSearchParams.toString()); // Prints a=b&a=c
// newSearchParams.toString() is implicitly called myURL.search = newSearchParams; console.log(myURL.href); // Prints https://example.org/?a=b&a=c newSearchParams.delete('a'); console.log(myURL.href); // Prints https://example.org/?a=b&a=c
- Annotations
- @JSType() @JSImport("url", "URLSearchParams") @native()
- Since
v7.5.0, v6.13.0
- class URL_ extends Object with StObject
Browser-compatible
URL
class, implemented by following the WHATWG URL Standard.Browser-compatible
URL
class, implemented by following the WHATWG URL Standard. [Examples of parsed URLs](https://url.spec.whatwg.org/#example-url-parsing) may be found in the Standard itself. TheURL
class is also available on the global object.In accordance with browser conventions, all properties of
URL
objects are implemented as getters and setters on the class prototype, rather than as data properties on the object itself. Thus, unlikelegacy urlObject
s, using thedelete
keyword on any properties ofURL
objects (e.g.delete myURL.protocol
,delete myURL.pathname
, etc) has no effect but will still returntrue
.- Annotations
- @JSType() @JSImport("url", "URL") @native()
- Since
v7.0.0, v6.13.0