From b4df58765d154b212496a4adbe4abc2e0fa3c885 Mon Sep 17 00:00:00 2001 From: Savely Savianok <1986developer@gmail.com> Date: Sun, 9 Feb 2025 20:54:10 +0300 Subject: [PATCH] fix: added validation for links --- setting/index.js | 8 +++++++- setting/utils/queryParser.js | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/setting/index.js b/setting/index.js index 9c136f4..434e9dc 100644 --- a/setting/index.js +++ b/setting/index.js @@ -5,13 +5,19 @@ let _props = null; AppSettingsPage({ build(props) { _props = props; + const storage = props.settingsStorage.getItem("TOTPs") ?? [] const totpEntrys = GetTOTPList(storage) const createButton = TextInput({ placeholder: "otpauth://", label: "Add new OTP Link", onChange: (changes) => { - storage.push(getTOTPByLink(changes)) + var link = getTOTPByLink(changes) + if(link == null){ + console.log("link is invalid") + return; + } + storage.push(link) updateStorage(storage) }, labelStyle: { diff --git a/setting/utils/queryParser.js b/setting/utils/queryParser.js index a1a9ad9..a63430c 100644 --- a/setting/utils/queryParser.js +++ b/setting/utils/queryParser.js @@ -33,7 +33,7 @@ export function getTOTPByLink(link) { getHashType(algorithm) ); } catch (err) { - throw new Error("Link is not valid"); + return null; } }