Skip to content

Commit c6d9b9e

Browse files
committed
fix(Groups): validate invite link hostname
1 parent 999e0bf commit c6d9b9e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/managers/GroupManager.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,10 @@ export default class GroupManager extends BaseManager<Group> implements GroupMan
104104
if (shareToken !== undefined) {
105105
return await this.joinWithToken(inviteLinkOrGroupID, shareToken)
106106
} else {
107-
const urlPath = new URL(inviteLinkOrGroupID).pathname
108-
const matches = urlPath.match(/.+\/(\d+)\/([A-Za-z0-9]+)$/)
107+
const inviteURL = new URL(inviteLinkOrGroupID)
108+
if (!inviteURL.hostname.endsWith('groupme.com'))
109+
throw new Error(`Invalid invite link\n-- URL: ${inviteLinkOrGroupID}`)
110+
const matches = inviteURL.pathname.match(/.+\/(\d+)\/([A-Za-z0-9]+)$/)
109111
if (matches === null) throw new Error(`Invalid invite link\n-- URL: ${inviteLinkOrGroupID}`)
110112
return await this.joinWithToken(matches[1], matches[2])
111113
}

0 commit comments

Comments
 (0)