Browse Source

Merge pull request #140 from pdxlocations/url-validation

Fix URL Validation
pull/143/head
Ben Meadors 3 years ago
committed by GitHub
parent
commit
68b207b67f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      package.json
  2. 9
      src/components/Dialog/ImportDialog.tsx

2
package.json

@ -1,6 +1,6 @@
{ {
"name": "meshtastic-web", "name": "meshtastic-web",
"version": "2.2.12-0", "version": "2.2.12-1",
"type": "module", "type": "module",
"description": "Meshtastic web client", "description": "Meshtastic web client",
"license": "GPL-3.0-only", "license": "GPL-3.0-only",

9
src/components/Dialog/ImportDialog.tsx

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

Loading…
Cancel
Save