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 | f84fc5e653d6d29add893b6d2573d04c91fd1d40 (patch) | |
tree | 794fc1c3e4c4791e091d785db0f45ae12c774677 /Timeline/ClientApp/src/app/utilities/url.ts | |
parent | fe950cad28ec6ff7bf6f399ddd31448180bc7601 (diff) | |
parent | 0a456da9e9cc0cf0244e80a3da5af26debd20841 (diff) | |
download | timeline-f84fc5e653d6d29add893b6d2573d04c91fd1d40.tar.gz timeline-f84fc5e653d6d29add893b6d2573d04c91fd1d40.tar.bz2 timeline-f84fc5e653d6d29add893b6d2573d04c91fd1d40.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;
}
|