From 0e2479559bab323b4e656d61f79b682b01c6449e Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Mon, 8 Jul 2019 20:51:17 -0700 Subject: [PATCH] fix: correctly parse hostname for instance block (#1328) --- src/routes/_actions/addInstance.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/routes/_actions/addInstance.js b/src/routes/_actions/addInstance.js index c91eb140..d1091e45 100644 --- a/src/routes/_actions/addInstance.js +++ b/src/routes/_actions/addInstance.js @@ -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)