From 0a01cac57baad9166bb21b30ef3e4e2fffb70553 Mon Sep 17 00:00:00 2001
From: Manav Rathi
= ({ code, otp, nextOTP }) => { color: "grey", }} > - {code.account} + {code.account ?? ""}
{ return { id, type: parseType(url), - account: _getAccount(uriPath), + account: parseAccount(url), issuer: _getIssuer(uriPath, uriParams), digits: parseDigits(url), period: parsePeriod(url), @@ -68,18 +68,9 @@ const parseType = (url: URL): Code["type"] => { throw new Error(`Unsupported code with host ${t}`); }; -const _getAccount = (uriPath: string): string => { - try { - const path = decodeURIComponent(uriPath); - if (path.includes(":")) { - return path.split(":")[1]; - } else if (path.includes("/")) { - return path.split("/")[1]; - } - } catch (e) { - return ""; - } -}; +/** Convert the pathname from "/ACME:user@example.org" => "user@example.org" */ +const parseAccount = (url: URL): string => + url.pathname.split(":").at(-1).split("/").at(-1); const _getIssuer = (uriPath: string, uriParams: { get?: any }): string => { try { diff --git a/web/apps/photos/package.json b/web/apps/photos/package.json index 1541878c5..0ec924b29 100644 --- a/web/apps/photos/package.json +++ b/web/apps/photos/package.json @@ -43,7 +43,6 @@ "similarity-transformation": "^0.0.1", "transformation-matrix": "^2.16", "uuid": "^9.0.1", - "vscode-uri": "^3.0.7", "xml-js": "^1.6.11", "zxcvbn": "^4.4.2" }, diff --git a/web/yarn.lock b/web/yarn.lock index 894a44dd0..aaa0d517a 100644 --- a/web/yarn.lock +++ b/web/yarn.lock @@ -4804,11 +4804,6 @@ void-elements@3.1.0: resolved "https://registry.yarnpkg.com/void-elements/-/void-elements-3.1.0.tgz#614f7fbf8d801f0bb5f0661f5b2f5785750e4f09" integrity sha512-Dhxzh5HZuiHQhbvTW9AMetFfBHDMYpo23Uo9btPXgdYP+3T5S+p+jgNy7spra+veYhBP2dCSgxR/i2Y02h5/6w== -vscode-uri@^3.0.7: - version "3.0.8" - resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-3.0.8.tgz#1770938d3e72588659a172d0fd4642780083ff9f" - integrity sha512-AyFQ0EVmsOZOlAnxoFOGOq1SQDWAB7C6aqMGS23svWAllfOaxbuFvcT8D1i8z3Gyn8fraVeZNNmN6e9bxxXkKw== - webidl-conversions@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871"