mirror of
https://github.com/zulip/zulip.git
synced 2025-11-09 16:37:23 +00:00
stream_data: Make slug regex a bit more readable.
This clarifies that the second group is purely for use internal to the regexp (it's there for the ? to act on) and won't be saved as a substring for the surrounding code to look at (like match[2]). In a hot path that could be a performance savings; here it just makes things a bit more explicit for the reader.
This commit is contained in:
@@ -271,7 +271,7 @@ export function slug_to_stream_id(slug: string): number | undefined {
|
||||
*/
|
||||
|
||||
// "New" (2018) format: ${stream_id}-${stream_name} .
|
||||
const match = /^(\d+)(-.*)?$/.exec(slug);
|
||||
const match = /^(\d+)(?:-.*)?$/.exec(slug);
|
||||
const newFormatStreamId = match ? Number.parseInt(match[1]!, 10) : null;
|
||||
if (newFormatStreamId && stream_info.get(newFormatStreamId)) {
|
||||
return newFormatStreamId;
|
||||
|
||||
Reference in New Issue
Block a user