diff --git a/src/js/Content/Features/Community/ProfileHome/FCommunityProfileLinks.svelte b/src/js/Content/Features/Community/ProfileHome/FCommunityProfileLinks.svelte index f5e5f865b..196ffdc98 100644 --- a/src/js/Content/Features/Community/ProfileHome/FCommunityProfileLinks.svelte +++ b/src/js/Content/Features/Community/ProfileHome/FCommunityProfileLinks.svelte @@ -2,6 +2,7 @@ import Settings from "@Options/Data/Settings"; import ProfileLink from "@Content/Modules/Community/ProfileLink.svelte"; import HTML from "@Core/Html/Html"; + import UrlUtils from "@Core/Utils/UrlUtils"; export let steamId: string; export let clear: boolean; @@ -55,7 +56,7 @@ {#if customLink.enabled} {customLink.name} diff --git a/src/js/Content/Features/Store/Common/ExtraLinks/AppLinks.svelte b/src/js/Content/Features/Store/Common/ExtraLinks/AppLinks.svelte index 14d1859a7..e40b68ded 100644 --- a/src/js/Content/Features/Store/Common/ExtraLinks/AppLinks.svelte +++ b/src/js/Content/Features/Store/Common/ExtraLinks/AppLinks.svelte @@ -5,6 +5,7 @@ import Settings from "@Options/Data/Settings"; import ExtraLink from "@Content/Features/Store/Common/ExtraLinks/ExtraLink.svelte"; import CommonExtraLinks from "@Content/Features/Common/CommonExtraLinks.svelte"; + import UrlUtils from "@Core/Utils/UrlUtils"; export let appid: number; export let communityAppid: number; @@ -66,9 +67,7 @@ {#each Settings.app_custom_link as link} {#if link.enabled} - {L(__viewOnWebsite, {"website": link.name})} diff --git a/src/js/Core/Utils/UrlUtils.ts b/src/js/Core/Utils/UrlUtils.ts new file mode 100644 index 000000000..9c107c221 --- /dev/null +++ b/src/js/Core/Utils/UrlUtils.ts @@ -0,0 +1,21 @@ + +export default class UrlUtils { + + public static escapeUserUrl(url: string, replacements: Record): string { + const result = new URL(url); + + /* + * For some reason + * for (const ... of result.searchParams.entries()) + * does not work, and I have no idea why (says it's not iterable) + */ + + result.searchParams.forEach((value, name, searchParams) => { + for (const [pattern, replacement] of Object.entries(replacements)) { + value = value.replace(`[${pattern}]`, replacement); + } + searchParams.set(name, value); + }); + return result.toString(); + } +}