Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate formatting of inscriptionId in getId() function #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

angrybirdcoiners
Copy link

Added regex to validate inscriptionId in getId() and removed positional assumption for inscriptionId

@@ -17,8 +17,8 @@ import { decode } from './content/cbor-x.mjs';
* const myId = getId();
*/
export const getId = () => {
let id = window.location.pathname.split('/')[2];
return id;
let rex = /\/([a-f0-9]{64}i[0-9]{1,3})\/?/i;
Copy link
Member

@elocremarc elocremarc Mar 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why a limit after i? The batch inscription index can be over 1000.

Suggested change
let rex = /\/([a-f0-9]{64}i[0-9]{1,3})\/?/i;
let rex = /([a-f0-9]{64}i[0-9]+)/i;

@elocremarc
Copy link
Member

@angrybirdcoiners Can add write tests for the regex function on expected URLs? Idk how to write a test in bun to actually get the window element. But we could just test the regex.
Btw the first 2 tests will fail until ordinals.com goes to V0.16.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants