API reference docs for QueryString
This commit is contained in:
@@ -970,13 +970,26 @@ jasmineRequire.ResultsNode = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
jasmineRequire.QueryString = function() {
|
jasmineRequire.QueryString = function() {
|
||||||
|
/**
|
||||||
|
* Reads and manipulates the query string.
|
||||||
|
* @since 2.0.0
|
||||||
|
*/
|
||||||
class QueryString {
|
class QueryString {
|
||||||
#getWindowLocation;
|
#getWindowLocation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param options Object with a getWindowLocation property, which should be
|
||||||
|
* a function returning the current value of window.location.
|
||||||
|
*/
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
this.#getWindowLocation = options.getWindowLocation;
|
this.#getWindowLocation = options.getWindowLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the specified query parameter and navigates to the resulting URL.
|
||||||
|
* @param {string} key
|
||||||
|
* @param {string} value
|
||||||
|
*/
|
||||||
navigateWithNewParam(key, value) {
|
navigateWithNewParam(key, value) {
|
||||||
this.#getWindowLocation().search = this.fullStringWithNewParam(
|
this.#getWindowLocation().search = this.fullStringWithNewParam(
|
||||||
key,
|
key,
|
||||||
@@ -984,12 +997,24 @@ jasmineRequire.QueryString = function() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new URL based on the current location, with the specified
|
||||||
|
* query parameter set.
|
||||||
|
* @param {string} key
|
||||||
|
* @param {string} value
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
fullStringWithNewParam(key, value) {
|
fullStringWithNewParam(key, value) {
|
||||||
const paramMap = this.#queryStringToParamMap();
|
const paramMap = this.#queryStringToParamMap();
|
||||||
paramMap[key] = value;
|
paramMap[key] = value;
|
||||||
return toQueryString(paramMap);
|
return toQueryString(paramMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the specified query parameter.
|
||||||
|
* @param {string} key
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
getParam(key) {
|
getParam(key) {
|
||||||
return this.#queryStringToParamMap()[key];
|
return this.#queryStringToParamMap()[key];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,24 @@
|
|||||||
jasmineRequire.QueryString = function() {
|
jasmineRequire.QueryString = function() {
|
||||||
|
/**
|
||||||
|
* Reads and manipulates the query string.
|
||||||
|
* @since 2.0.0
|
||||||
|
*/
|
||||||
class QueryString {
|
class QueryString {
|
||||||
#getWindowLocation;
|
#getWindowLocation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param options Object with a getWindowLocation property, which should be
|
||||||
|
* a function returning the current value of window.location.
|
||||||
|
*/
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
this.#getWindowLocation = options.getWindowLocation;
|
this.#getWindowLocation = options.getWindowLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the specified query parameter and navigates to the resulting URL.
|
||||||
|
* @param {string} key
|
||||||
|
* @param {string} value
|
||||||
|
*/
|
||||||
navigateWithNewParam(key, value) {
|
navigateWithNewParam(key, value) {
|
||||||
this.#getWindowLocation().search = this.fullStringWithNewParam(
|
this.#getWindowLocation().search = this.fullStringWithNewParam(
|
||||||
key,
|
key,
|
||||||
@@ -13,12 +26,24 @@ jasmineRequire.QueryString = function() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new URL based on the current location, with the specified
|
||||||
|
* query parameter set.
|
||||||
|
* @param {string} key
|
||||||
|
* @param {string} value
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
fullStringWithNewParam(key, value) {
|
fullStringWithNewParam(key, value) {
|
||||||
const paramMap = this.#queryStringToParamMap();
|
const paramMap = this.#queryStringToParamMap();
|
||||||
paramMap[key] = value;
|
paramMap[key] = value;
|
||||||
return toQueryString(paramMap);
|
return toQueryString(paramMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the specified query parameter.
|
||||||
|
* @param {string} key
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
getParam(key) {
|
getParam(key) {
|
||||||
return this.#queryStringToParamMap()[key];
|
return this.#queryStringToParamMap()[key];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user