mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
slugs: Fix regex for legacy stream slugs.
This prevents a bug where we interpret "2something" as a modern slug instead of a legacy stream name. The bug was probably somewhat unlikely to happen in practice, since it only manifests if 2 is an actual stream_id.
This commit is contained in:
@@ -116,7 +116,12 @@ run_test("basics", () => {
|
|||||||
assert.equal(stream_data.slug_to_name("2-whatever"), "social");
|
assert.equal(stream_data.slug_to_name("2-whatever"), "social");
|
||||||
assert.equal(stream_data.slug_to_name("2"), "social");
|
assert.equal(stream_data.slug_to_name("2"), "social");
|
||||||
|
|
||||||
|
// legacy
|
||||||
assert.equal(stream_data.slug_to_name("25-or-6-to-4"), "25-or-6-to-4");
|
assert.equal(stream_data.slug_to_name("25-or-6-to-4"), "25-or-6-to-4");
|
||||||
|
assert.equal(stream_data.slug_to_name("2something"), "2something");
|
||||||
|
|
||||||
|
assert.equal(stream_data.slug_to_name("99-whatever"), "99-whatever");
|
||||||
|
assert.equal(stream_data.slug_to_name("99whatever"), "99whatever");
|
||||||
});
|
});
|
||||||
|
|
||||||
run_test("renames", () => {
|
run_test("renames", () => {
|
||||||
|
|||||||
@@ -328,7 +328,7 @@ exports.slug_to_name = function (slug) {
|
|||||||
GitHub conversations. We migrated to modern slugs in
|
GitHub conversations. We migrated to modern slugs in
|
||||||
early 2018.
|
early 2018.
|
||||||
*/
|
*/
|
||||||
const m = /^(\d+)(-.*)?/.exec(slug);
|
const m = /^(\d+)(-.*)?$/.exec(slug);
|
||||||
if (m) {
|
if (m) {
|
||||||
const stream_id = Number.parseInt(m[1], 10);
|
const stream_id = Number.parseInt(m[1], 10);
|
||||||
const sub = subs_by_stream_id.get(stream_id);
|
const sub = subs_by_stream_id.get(stream_id);
|
||||||
|
|||||||
Reference in New Issue
Block a user