diff --git a/app/lib/methods/helpers/parseQuery.js b/app/lib/methods/helpers/parseQuery.js deleted file mode 100644 index 30f1bb3c..00000000 --- a/app/lib/methods/helpers/parseQuery.js +++ /dev/null @@ -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; - }, {}); -} diff --git a/app/lib/methods/helpers/parseQuery.ts b/app/lib/methods/helpers/parseQuery.ts new file mode 100644 index 00000000..c6e2bb5f --- /dev/null +++ b/app/lib/methods/helpers/parseQuery.ts @@ -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; + }, {}); +}