Skip to content

Commit

Permalink
Merge pull request #140 from pdxlocations/url-validation
Browse files Browse the repository at this point in the history
Fix URL Validation
  • Loading branch information
thebentern authored Nov 2, 2023
2 parents a8c45cc + 437db3c commit 68b207b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "meshtastic-web",
"version": "2.2.12-0",
"version": "2.2.12-1",
"type": "module",
"description": "Meshtastic web client",
"license": "GPL-3.0-only",
Expand Down
9 changes: 5 additions & 4 deletions src/components/Dialog/ImportDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 68b207b

Please sign in to comment.