]> git.ardis.lu - safe-owners/commitdiff
Allow leading and trailing whitespace in safe address
authorArdis Lu <ardisglu@gmail.com>
Sat, 7 Dec 2024 07:03:23 +0000 (23:03 -0800)
committerArdis Lu <ardisglu@gmail.com>
Sat, 7 Dec 2024 07:03:23 +0000 (23:03 -0800)
Useful when copying addresses from documents, which sometimes adds a trailing space.

index.html

index 70cfe9a1e9c8f954c7b7c0e73a883a7fe5fe9dd5..3d74fdca8e14472966e28eafe25cb521cdb27082 100644 (file)
 
   <form>
     <label for="safe">Safe Smart Contract</label>
-    <input id="safe" name="safe" pattern="(.+:)?0x[a-fA-F0-9]{40}" placeholder="0x8CF60B289f8d31F737049B590b5E4285Ff0Bd1D1" value="0x8CF60B289f8d31F737049B590b5E4285Ff0Bd1D1" required>
+    <input id="safe" name="safe" pattern="\s*(.+:)?0x[a-fA-F0-9]{40}\s*" placeholder="0x8CF60B289f8d31F737049B590b5E4285Ff0Bd1D1" value="0x8CF60B289f8d31F737049B590b5E4285Ff0Bd1D1" required>
 
     <label for="rpc">JSON-RPC</label>
     <input id="rpc" name="rpc" type="url" placeholder="https://ethereum.publicnode.com" value="https://ethereum.publicnode.com" required>
       const { safe, rpc } = Object.fromEntries(new FormData(e.target));
       tree.innerHTML = '';
       allAddresses.length = 0;
-      await insertTreeNode(tree, safe.replace(/^.+:/, '').toLowerCase(), rpc);
+      await insertTreeNode(tree, safe.replace(/^.+:/, '').trim().toLowerCase(), rpc);
       document.querySelectorAll('svg').forEach(svg => {
         svg.addEventListener('mouseover', e => highlightAddress(tree, svg.closest('li').textContent.substring(0, 42)));
         svg.addEventListener('mouseout', e => CSS.highlights.clear());
This page took 0.04384 seconds and 4 git commands to generate.