diff --git a/frontend/src/lib/components/PronounLink.svelte b/frontend/src/lib/components/PronounLink.svelte index 317dc19..d295a3a 100644 --- a/frontend/src/lib/components/PronounLink.svelte +++ b/frontend/src/lib/components/PronounLink.svelte @@ -11,18 +11,28 @@ return pronouns.display_text; } else { const split = pronouns.pronouns.split("/"); - if (split.length < 2) return split.join("/"); - else return split.slice(0, 2).join("/"); + if (split.length === 5) return split.splice(0, 2).join("/"); + return pronouns.pronouns; } }; let link: string; let shouldLink: boolean; - $: link = pronouns.display_text - ? `${pronouns.pronouns},${pronouns.display_text}` - : pronouns.pronouns; + $: link = linkPronouns(pronouns); $: shouldLink = pronouns.pronouns.split("/").length === 5; + + const linkPronouns = (pronouns: Pronoun) => { + const linkBase = pronouns.pronouns + .split("/") + .map((snippet) => encodeURIComponent(snippet)) + .join("/"); + + if (pronouns.display_text) { + return `${linkBase},${encodeURIComponent(pronouns.display_text)}`; + } + return linkBase; + }; {#if shouldLink} diff --git a/frontend/src/routes/pronouns/[...pronouns]/+page.ts b/frontend/src/routes/pronouns/[...pronouns]/+page.ts index 60f252f..6ab0564 100644 --- a/frontend/src/routes/pronouns/[...pronouns]/+page.ts +++ b/frontend/src/routes/pronouns/[...pronouns]/+page.ts @@ -6,7 +6,7 @@ import pronounsRaw from "$lib/pronouns.json"; const pronouns = pronounsRaw as PronounsJson; export const load = (async ({ params }) => { - const [param, displayText] = params.pronouns.split(","); + const [param, displayText] = decodeURIComponent(params.pronouns).split(","); const arr = param.split("/"); if (arr.length === 0 || params.pronouns === "") {