Chore: Migrate methods/helpers/parseQuery to Typescript (#3742)
* Chore: Migrate methods/helpers/parseQuery to Typescript * tweak in example
This commit is contained in:
parent
941a21dac6
commit
9b369e548e
|
@ -1,7 +0,0 @@
|
|||
export default function (query) {
|
||||
return (/^[?#]/.test(query) ? query.slice(1) : query).split('&').reduce((params, param) => {
|
||||
const [key, value] = param.split('=');
|
||||
params[key] = value ? decodeURIComponent(value.replace(/\+/g, ' ')) : '';
|
||||
return params;
|
||||
}, {});
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
/**
|
||||
*
|
||||
* @example
|
||||
* parseQuery("host=open.rocket.chat&path=channel/general/thread/meRK2nfjR99MjLn55")
|
||||
* // the return will be
|
||||
* {
|
||||
* host: "open.rocket.chat",
|
||||
* path: "channel/general/thread/meRK2nfjR99MjLn55"
|
||||
* }
|
||||
*/
|
||||
|
||||
export default function (query: string) {
|
||||
return (/^[?#]/.test(query) ? query.slice(1) : query).split('&').reduce((params: { [key: string]: string }, param) => {
|
||||
const [key, value] = param.split('=');
|
||||
params[key] = value ? decodeURIComponent(value.replace(/\+/g, ' ')) : '';
|
||||
return params;
|
||||
}, {});
|
||||
}
|
Loading…
Reference in New Issue