Skip to content

Commit 2a73e3d

Browse files
chrisbobbegnprice
authored andcommitted
getNearOperandFromLink: Check near operand is digits before parsing
1 parent e887323 commit 2a73e3d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/utils/internalLinks.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,14 @@ export const getNearOperandFromLink = (url: string, realm: URL): number => {
254254

255255
// We expect an operand to directly follow its operator.
256256
const nearOperandIndex = nearOperatorIndex + 1;
257-
return parseInt(hashSegments[nearOperandIndex], 10);
257+
258+
const nearOperandStr = hashSegments[nearOperandIndex];
259+
// Must look like a message ID
260+
if (!/^[0-9]+$/.test(nearOperandStr)) {
261+
return 0;
262+
}
263+
264+
return parseInt(nearOperandStr, 10);
258265
};
259266

260267
export const getStreamTopicUrl = (

0 commit comments

Comments
 (0)