Imported libraries, removed next-basics.
This commit is contained in:
1 parent
31266cb1ac
commit
113022ed17
44 files changed
+361
-180
No files matched your search
@@ -0,0 +1,40 @@
|
||||
export function getQueryString(params: object = {}): string {
|
||||
const searchParams = new URLSearchParams();
|
||||
|
||||
Object.entries(params).forEach(([key, value]) => {
|
||||
if (value !== undefined) {
|
||||
searchParams.append(key, value);
|
||||
}
|
||||
});
|
||||
|
||||
return searchParams.toString();
|
||||
}
|
||||
|
||||
export function buildUrl(url: string, params: object = {}): string {
|
||||
const queryString = getQueryString(params);
|
||||
return `${url}${queryString && '?' + queryString}`;
|
||||
}
|
||||
|
||||
export function safeDecodeURI(s: string | undefined | null): string | undefined | null {
|
||||
if (s === undefined || s === null) {
|
||||
return s;
|
||||
}
|
||||
|
||||
try {
|
||||
return decodeURI(s);
|
||||
} catch (e) {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
export function safeDecodeURIComponent(s: string | undefined | null): string | undefined | null {
|
||||
if (s === undefined || s === null) {
|
||||
return s;
|
||||
}
|
||||
|
||||
try {
|
||||
return decodeURIComponent(s);
|
||||
} catch (e) {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user