Skip to content

Conversation

@angrybirdcoiners
Copy link

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

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