From 980fd2f97601e539f8218b05f3765fa06b4eb1c9 Mon Sep 17 00:00:00 2001 From: Austin Riba Date: Mon, 28 Feb 2022 11:54:06 -0800 Subject: [PATCH] streams: Fix malformed stream name slugs. The stream_data.id_to_slug and stream_data.name_to_slug functions mistakenly used Javascript's String.replace method, this commit changes it to use String.replaceAll, the result being slugs generated from streams with names greater than 2 words are now properly formatted. --- frontend_tests/node_tests/markdown.js | 4 ++-- static/js/stream_data.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend_tests/node_tests/markdown.js b/frontend_tests/node_tests/markdown.js index 88263406f2..916a6827b6 100644 --- a/frontend_tests/node_tests/markdown.js +++ b/frontend_tests/node_tests/markdown.js @@ -556,12 +556,12 @@ test("marked", () => { { input: "#**& & &**", expected: - '

#& & &

', + '

#& & &

', }, { input: "#**& & &>& & &**", expected: - '

#& & & > & & &

', + '

#& & & > & & &

', }, ]; diff --git a/static/js/stream_data.js b/static/js/stream_data.js index 91137c2025..673de04c2e 100644 --- a/static/js/stream_data.js +++ b/static/js/stream_data.js @@ -282,7 +282,7 @@ export function id_to_slug(stream_id) { // The name part of the URL doesn't really matter, so we try to // make it pretty. - name = name.replace(" ", "-"); + name = name.replaceAll(" ", "-"); return stream_id + "-" + name; } @@ -296,7 +296,7 @@ export function name_to_slug(name) { // The name part of the URL doesn't really matter, so we try to // make it pretty. - name = name.replace(" ", "-"); + name = name.replaceAll(" ", "-"); return stream_id + "-" + name; }