[bugfix/frontend] Decode URI component domain before showing on frontend (#2043)

This commit is contained in:
tobi 2023-07-31 12:18:27 +02:00 committed by GitHub
parent a5a80b4bbe
commit de148e9f9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,11 +38,14 @@ module.exports = function InstanceDetail({ baseUrl }) {
const { data: blockedInstances = {}, isLoading } = query.useInstanceBlocksQuery();
let [_match, { domain }] = useRoute(`${baseUrl}/:domain`);
if (domain == "view") { // from form field submission
if (domain == "view") {
// Retrieve domain from form field submission.
domain = (new URL(document.location)).searchParams.get("domain");
}
// Normalize / decode domain (it may be URL-encoded).
domain = decodeURIComponent(domain);
const existingBlock = React.useMemo(() => {
return blockedInstances[domain];
}, [blockedInstances, domain]);