hash: Use encoding for slugs in dm narrow hashes.

Slugs in dm urls aren't really passed through url decoding and
shouldn't throw any error currently if hashReplacement aren't enforced.
But we still encode them in this commit to make this consistent.
This commit is contained in:
Pratik Chanda
2025-10-25 00:45:46 +05:30
committed by Tim Abbott
parent f86654ba5f
commit 152ad3bf3d

View File

@@ -2,6 +2,7 @@ import md5 from "blueimp-md5";
import assert from "minimalistic-assert"; import assert from "minimalistic-assert";
import * as z from "zod/mini"; import * as z from "zod/mini";
import * as internal_url from "../shared/src/internal_url.ts";
import * as typeahead from "../shared/src/typeahead.ts"; import * as typeahead from "../shared/src/typeahead.ts";
import * as blueslip from "./blueslip.ts"; import * as blueslip from "./blueslip.ts";
@@ -650,7 +651,7 @@ export function pm_perma_link(message: Message): string | undefined {
} }
export function get_slug_from_full_name(full_name: string): string { export function get_slug_from_full_name(full_name: string): string {
return full_name.replaceAll(/[ "%/<>`\p{C}]+/gu, "-"); return internal_url.encodeHashComponent(full_name.replaceAll(/[ "%/<>`\p{C}]+/gu, "-"));
} }
export function pm_with_url(message: Message | MessageWithBooleans): string | undefined { export function pm_with_url(message: Message | MessageWithBooleans): string | undefined {