Browse Source

validation of string not URL

pull/140/head
pdxlocations 3 years ago
parent
commit
23a1b41330
  1. 9
      src/components/Dialog/ImportDialog.tsx

9
src/components/Dialog/ImportDialog.tsx

@ -34,11 +34,12 @@ export const ImportDialog = ({
useEffect(() => {
const base64String = QRCodeURL.split("e/#")[1]
?.replace(/-/g, "+")
.replace(/_/g, "/")
.padEnd(QRCodeURL.length + ((4 - (QRCodeURL.length % 4)) % 4), "=");
const paddedString = base64String
?.padEnd(base64String.length + ((4 - (base64String.length % 4)) % 4), "=")
.replace(/-/g, "+")
.replace(/_/g, "/");
try {
setChannelSet(Protobuf.ChannelSet.fromBinary(toByteArray(base64String)));
setChannelSet(Protobuf.ChannelSet.fromBinary(toByteArray(paddedString)));
setValidURL(true);
} catch (error) {
setValidURL(false);

Loading…
Cancel
Save