From e55ae3710dc3847b5c6db9bc7a55f902f5fdcfa1 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Mon, 30 Aug 2021 15:18:05 -0700 Subject: [PATCH] Handle slashes in usernames (but not anything else) --- src/Link.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Link.js b/src/Link.js index 079d7be..bbf5ea5 100644 --- a/src/Link.js +++ b/src/Link.js @@ -109,10 +109,17 @@ export class Link { linkStr = linkStr.substr(2); } - const [identifier, eventId] = linkStr.split("/"); + const lastSlash = linkStr.lastIndexOf("/"); + let identifier, eventId; + if (lastSlash !== -1) { + identifier = linkStr.substring(0, lastSlash); + eventId = linkStr.substring(lastSlash+1); + } else { + identifier = linkStr; + } let matches; - matches = USERID_PATTERN.exec(identifier); + matches = USERID_PATTERN.exec(identifier) || USERID_PATTERN.exec(`${identifier}/${eventId}`); if (matches) { const server = matches[2]; const localPart = matches[1];