diff --git a/src/lib/router.ts b/src/lib/router.ts index 888c8eb24..655cfdd61 100644 --- a/src/lib/router.ts +++ b/src/lib/router.ts @@ -169,9 +169,10 @@ function extractBaseUrl(hostAndPort: string): BaseUrl { return { hostname, port: Number(port), - scheme: utils.isLocal(hostname) - ? "http" - : config.nodes.defaultHttpdScheme, + scheme: + utils.isLocal(hostname) || utils.isOnion(hostname) + ? "http" + : config.nodes.defaultHttpdScheme, }; } else { return { diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 8ed5d8bd1..017728969 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -264,6 +264,11 @@ export function isLocal(addr: string): boolean { ); } +// Check whether the given domain name is an onion domain name. +export function isOnion(addr: string): boolean { + return addr.endsWith(".onion"); +} + // Get the gravatar URL of an email. export function gravatarURL(email: string): string { const address = email.trim().toLowerCase();