Change editor to comply with domain rules MOD-537 (#118)

* insert link rules

* change error message
This commit is contained in:
Carter
2023-10-23 17:02:08 -07:00
committed by GitHub
parent 91f79d2be0
commit 16a39b364c

View File

@@ -460,7 +460,7 @@ function validateURL() {
}
function cleanUrl(input: string): string {
let url
let url: URL
// Attempt to validate and parse the URL
try {
@@ -479,6 +479,12 @@ function cleanUrl(input: string): string {
url.protocol = 'https:'
}
// Block certain domains for compliance
const blockedDomains = ['forgecdn', 'cdn.discordapp', 'media.discordapp']
if (blockedDomains.some((domain) => url.hostname.includes(domain))) {
throw new Error('Invalid URL. This domain is not allowed.')
}
return url.toString()
}