fedimbed: fix where its actually crashing and also slight optimization
This commit is contained in:
parent
6bff2e9eb3
commit
99510766d4
1 changed files with 7 additions and 2 deletions
|
@ -724,10 +724,15 @@ events.add("messageCreate", "fedimbed", async function (msg) {
|
||||||
.trim()
|
.trim()
|
||||||
.replace("@\u200b", "@")
|
.replace("@\u200b", "@")
|
||||||
.replace("@%E2%80%8B", "@");
|
.replace("@%E2%80%8B", "@");
|
||||||
|
let urlObj;
|
||||||
|
try {
|
||||||
|
urlObj = new URL(url);
|
||||||
|
} catch {
|
||||||
|
// noop
|
||||||
|
}
|
||||||
for (const service of Object.keys(PATH_REGEX)) {
|
for (const service of Object.keys(PATH_REGEX)) {
|
||||||
const regex = PATH_REGEX[service];
|
const regex = PATH_REGEX[service];
|
||||||
const urlObj = new URL(url);
|
if (urlObj && regex.test(urlObj.pathname)) {
|
||||||
if (regex.test(urlObj.pathname)) {
|
|
||||||
logger.verbose(
|
logger.verbose(
|
||||||
"fedimbed",
|
"fedimbed",
|
||||||
`Hit "${service}" for "${url}", processing now.`
|
`Hit "${service}" for "${url}", processing now.`
|
||||||
|
|
Loading…
Reference in a new issue