mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-27 10:03:08 +02:00
Revert "Update load.ts"
This reverts commitcf9e8ed39e
, commit67792fcb5e
, and commitc7e8c27ce6
.
This commit is contained in:
parent
c7e8c27ce6
commit
9595a56346
1 changed files with 2 additions and 10 deletions
|
@ -47,22 +47,14 @@ export default function load() {
|
|||
return Object.assign(config, mixin);
|
||||
}
|
||||
|
||||
function tryCreateUrl(url: string) {
|
||||
function validateUrl(url: string) {
|
||||
try {
|
||||
return new URL(url);
|
||||
} catch (e) {
|
||||
throw `url="${url}" is not a valid URL.`;
|
||||
throw `url="${url}" is not a valid URL`;
|
||||
}
|
||||
}
|
||||
|
||||
function validateUrl(url: string) {
|
||||
const result = tryCreateUrl(url);
|
||||
if (result.pathname.replace('/', '').length) throw `url="${url}" is not a valid URL, has a pathname.`;
|
||||
if (!url.includes(result.host)) throw `url="${url}" is not a valid URL, has an invalid hostname.`;
|
||||
if (!/^https?:$/.test(result.protocol)) throw `url="${url}" is not a valid URL, has an invalid protocol.`;
|
||||
return result;
|
||||
}
|
||||
|
||||
function normalizeUrl(url: string) {
|
||||
return url.endsWith('/') ? url.substr(0, url.length - 1) : url;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue