Fix URL gen
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Dominic Grimm 2022-08-03 09:56:22 +02:00
parent 1ef75af853
commit 57a2d0f86e
3 changed files with 13 additions and 4 deletions

View file

@ -30,6 +30,7 @@
"svelte-preprocess": "^4.10.6", "svelte-preprocess": "^4.10.6",
"tslib": "^2.3.1", "tslib": "^2.3.1",
"typescript": "^4.7.4", "typescript": "^4.7.4",
"url-join": "^5.0.0",
"vite": "^3.0.0" "vite": "^3.0.0"
}, },
"type": "module", "type": "module",

View file

@ -1,5 +1,7 @@
export const API_ROOT_URL = new URL("http://techgames.gnetx.com/infoscreen"); import urlJoin from "url-join";
export const CONTENT_ROOT_URL = new URL("/listings", API_ROOT_URL);
export const API_ROOT_URL = "http://techgames.gnetx.com/infoscreen";
export const CONTENT_ROOT_URL = urlJoin(API_ROOT_URL, "/listings");
export enum ListingType { export enum ListingType {
IMAGE = "IMAGE", IMAGE = "IMAGE",
@ -25,6 +27,7 @@ export async function fetchData(): Promise<Data> {
return await response.json(); return await response.json();
} }
export function generateContentURL(content: string): URL { export function generateContentURL(content: string): string {
return new URL(`/${encodeURIComponent(content)}`, CONTENT_ROOT_URL); // return new URL(`/${encodeURIComponent(content)}`, CONTENT_ROOT_URL);
return urlJoin(CONTENT_ROOT_URL, encodeURIComponent(content));
} }

View file

@ -1726,6 +1726,11 @@ uri-js@^4.2.2:
dependencies: dependencies:
punycode "^2.1.0" punycode "^2.1.0"
url-join@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/url-join/-/url-join-5.0.0.tgz#c2f1e5cbd95fa91082a93b58a1f42fecb4bdbcf1"
integrity sha512-n2huDr9h9yzd6exQVnH/jU5mr+Pfx08LRXXZhkLLetAMESRj+anQsTAh940iMrIetKAmry9coFuZQ2jY8/p3WA==
util-deprecate@^1.0.1: util-deprecate@^1.0.1:
version "1.0.2" version "1.0.2"
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"