diff options
author | crupest <crupest@outlook.com> | 2020-08-03 02:24:48 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-03 02:24:48 +0800 |
commit | 66417650b46f27f8238cc6997e2ff14579c1244a (patch) | |
tree | 2ea398e3bc8189a8777c800fcf8a3845d604a652 /Timeline/ClientApp/src/app/utilities/url.ts | |
parent | 3d014eee30cf91c2e2c19af5c5140db137ccf225 (diff) | |
parent | ccebcc9a3704dc2056513042f717c321374c5350 (diff) | |
download | timeline-66417650b46f27f8238cc6997e2ff14579c1244a.tar.gz timeline-66417650b46f27f8238cc6997e2ff14579c1244a.tar.bz2 timeline-66417650b46f27f8238cc6997e2ff14579c1244a.zip |
Merge pull request #130 from crupest/offline-timeline
Save timeline locally.
Diffstat (limited to 'Timeline/ClientApp/src/app/utilities/url.ts')
-rw-r--r-- | Timeline/ClientApp/src/app/utilities/url.ts | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/Timeline/ClientApp/src/app/utilities/url.ts b/Timeline/ClientApp/src/app/utilities/url.ts index 0b8623a2..90923fd2 100644 --- a/Timeline/ClientApp/src/app/utilities/url.ts +++ b/Timeline/ClientApp/src/app/utilities/url.ts @@ -34,8 +34,19 @@ export function updateQueryString( }
export function applyQueryParameters<T>(url: string, query: T): string {
+ if (query == null) return url;
+
for (const [key, value] of Object.entries(query)) {
- url = updateQueryString(key, String(value), url);
+ if (typeof value === 'string') url = updateQueryString(key, value, url);
+ else if (typeof value === 'number')
+ url = updateQueryString(key, String(value), url);
+ else if (typeof value === 'boolean')
+ url = updateQueryString(key, value ? 'true' : 'false', url);
+ else if (value instanceof Date)
+ url = updateQueryString(key, value.toISOString(), url);
+ else {
+ console.error('Unknown query parameter type. Param: ', value);
+ }
}
return url;
}
|