Define remark host in runtime (#325)

* convert closest-polyfill to ts

* make remark respect host property in client setup
This commit is contained in:
Misha Vyrtsev
2019-05-13 10:51:17 -05:00
committed by Umputun
parent 53f2f82e05
commit 61e594786c
13 changed files with 138 additions and 70 deletions
+22
View File
@@ -0,0 +1,22 @@
/** converts widnow.location.search into object */
export function parseQuery(search: string): { [key: string]: string } {
if (search.length < 2) return {};
return search
.substr(1)
.split('&')
.map(
(chunk): [string, string] => {
const parts = chunk.split('=');
if (parts.length < 2) {
parts[1] = '';
} else {
parts[1] = decodeURIComponent(parts[1]);
}
return parts as [string, string];
}
)
.reduce<{ [key: string]: string }>((c, x) => {
c[x[0]] = x[1];
return c;
}, {});
}