mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +00:00
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:
@@ -556,12 +556,12 @@ test("marked", () => {
|
|||||||
{
|
{
|
||||||
input: "#**& & &**",
|
input: "#**& & &**",
|
||||||
expected:
|
expected:
|
||||||
'<p><a class="stream" data-stream-id="5" href="/#narrow/stream/5-.26-.26.20.26amp.3B">#& & &amp;</a></p>',
|
'<p><a class="stream" data-stream-id="5" href="/#narrow/stream/5-.26-.26-.26amp.3B">#& & &amp;</a></p>',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
input: "#**& & &amp;>& & &amp;**",
|
input: "#**& & &amp;>& & &amp;**",
|
||||||
expected:
|
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;</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;</a></p>',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
// The name part of the URL doesn't really matter, so we try to
|
||||||
// make it pretty.
|
// make it pretty.
|
||||||
name = name.replace(" ", "-");
|
name = name.replaceAll(" ", "-");
|
||||||
|
|
||||||
return stream_id + "-" + name;
|
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
|
// The name part of the URL doesn't really matter, so we try to
|
||||||
// make it pretty.
|
// make it pretty.
|
||||||
name = name.replace(" ", "-");
|
name = name.replaceAll(" ", "-");
|
||||||
|
|
||||||
return stream_id + "-" + name;
|
return stream_id + "-" + name;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user