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.
This commit is contained in:
Austin Riba 2022-02-28 11:54:06 -08:00 committed by Tim Abbott
parent 8ed7dcf4c0
commit 980fd2f976
2 changed files with 4 additions and 4 deletions

View File

@ -556,12 +556,12 @@ test("marked", () => {
{
input: "#**& & &**",
expected:
'<p><a class="stream" data-stream-id="5" href="/#narrow/stream/5-.26-.26.20.26amp.3B">#&amp; &amp; &amp;amp;</a></p>',
'<p><a class="stream" data-stream-id="5" href="/#narrow/stream/5-.26-.26-.26amp.3B">#&amp; &amp; &amp;amp;</a></p>',
},
{
input: "#**& &amp; &amp;amp;>& &amp; &amp;amp;**",
expected:
'<p><a class="stream-topic" data-stream-id="5" href="/#narrow/stream/5-.26-.26.20.26amp.3B/topic/.26.20.26.20.26amp.3B">#&amp; &amp; &amp;amp; &gt; &amp; &amp; &amp;amp;</a></p>',
'<p><a class="stream-topic" data-stream-id="5" href="/#narrow/stream/5-.26-.26-.26amp.3B/topic/.26.20.26.20.26amp.3B">#&amp; &amp; &amp;amp; &gt; &amp; &amp; &amp;amp;</a></p>',
},
];

View File

@ -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;
}