1
0
mirror of https://github.com/bitwarden/browser synced 2026-01-30 08:13:44 +00:00

ts-strict: Fix possibly null on parsedOrigin.hostname

This commit is contained in:
Daniel James Smith
2026-01-15 15:04:28 +01:00
parent 984394cff2
commit 9bcbf3dfcb

View File

@@ -48,7 +48,12 @@ export function isValidRpId(rpId: string, origin: string) {
if (rpId !== "localhost" && !rpId.includes(".")) {
return false;
}
if (parsedOrigin.hostname !== "localhost" && !parsedOrigin.hostname.includes(".")) {
if (
parsedOrigin.hostname != null &&
parsedOrigin.hostname !== "localhost" &&
!parsedOrigin.hostname.includes(".")
) {
return false;
}
@@ -65,7 +70,7 @@ export function isValidRpId(rpId: string, origin: string) {
// Check if origin is a subdomain of rpId
// This prevents "evilaccounts.example.com" from matching "accounts.example.com"
if (parsedOrigin.hostname.endsWith("." + rpId)) {
if (parsedOrigin.hostname != null && parsedOrigin.hostname.endsWith("." + rpId)) {
return true;
}