Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

utils: Fix decode_stream_topic_from_url to pass origin to construct url.

Harsh0b3f0273e604
diff --git a/web/src/hash_util.ts b/web/src/hash_util.ts
index 15d61700483..261cd8b79de 100644
--- a/web/src/hash_util.ts
+++ b/web/src/hash_util.ts
@@ -323,7 +323,7 @@ export function decode_stream_topic_from_url(
url_str: string,
): {stream_id: number; topic_name?: string; message_id?: string} | null {
try {
- const url = new URL(url_str);
+ const url = new URL(url_str, window.location.origin);
if (url.origin !== window.location.origin || !url.hash.startsWith("#narrow")) {
return null;
}
diff --git a/web/src/rendered_markdown.ts b/web/src/rendered_markdown.ts
index 690932e06e5..05c9fd9e0be 100644
--- a/web/src/rendered_markdown.ts
+++ b/web/src/rendered_markdown.ts
@@ -239,9 +239,7 @@ export const update_elements = ($content: JQuery): void => {
$content.find("a.stream-topic, a.message-link").each(function (): void {
const narrow_url = $(this).attr("href");
assert(narrow_url !== undefined);
- const channel_topic = hash_util.decode_stream_topic_from_url(
- window.location.origin + narrow_url,
- );
+ const channel_topic = hash_util.decode_stream_topic_from_url(narrow_url);
assert(channel_topic !== null);
const channel_name = sub_store.maybe_get_stream_name(channel_topic.stream_id);
if (channel_name !== undefined && $(this).find(".highlight").length === 0) {