Skip to content

Commit

Permalink
fix isValidMessageURL
Browse files Browse the repository at this point in the history
  • Loading branch information
catplvsplus committed Oct 29, 2023
1 parent b17a7e9 commit 5b4b3cc
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/utils/src/classes/MessageURLData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,18 @@ export class MessageURLData<InGuild extends boolean = boolean, Fetched extends b
}

public static isValidMessageURL(url: string|URL): boolean {
const structure = url instanceof URL ? url : new URL(url);
const path = structure.pathname.split('/').filter(Boolean);
try {
const structure = url instanceof URL ? url : new URL(url);
const path = structure.pathname.split('/').filter(Boolean);

if (path.length < 4) return false;
if (path.length < 4) return false;

const type = path.shift() as 'channels';
if (type !== 'channels') return false;
const type = path.shift() as 'channels';
if (type !== 'channels') return false;

return true;
return true;
} catch (err) {
return false;
}
}
}

0 comments on commit 5b4b3cc

Please sign in to comment.