fix: correctly parse hostname for instance block (#1328)

This commit is contained in:
Nolan Lawson 2019-07-08 20:51:17 -07:00 committed by GitHub
parent 6b40b2efbf
commit 0e2479559b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -23,7 +23,8 @@ async function redirectToOauth () {
if (Object.keys(loggedInInstances).includes(instanceNameInSearch)) {
throw createKnownError(`You've already logged in to ${instanceNameInSearch}`)
}
if (DOMAIN_BLOCKS.some(domain => new RegExp(`(?:\\.|^)${domain}$`, 'i').test(instanceNameInSearch))) {
let instanceHostname = new URL(`http://${instanceNameInSearch}`).hostname
if (DOMAIN_BLOCKS.some(domain => new RegExp(`(?:\\.|^)${domain}$`, 'i').test(instanceHostname))) {
throw createKnownError('This service is blocked')
}
let registrationPromise = registerApplication(instanceNameInSearch, REDIRECT_URI)