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

Regex in isFriendly should be anchored #65

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

Conversation

kolpav
Copy link

@kolpav kolpav commented Feb 23, 2025

I think I found few issues with addresses.

  1. regex in isFriendly should be anchored otherwise it returns true for invalid addresses
    parse fails as it should, problem is isFriendly not parseFriendly
  2. addresses for which parseRaw throws should also return false from isRaw
  3. addresses for which parseFriendly throws should also return false from isFriendly

You can verify by using my tests without change in isFriendly and see that address !@#$%^&*AAAAAAAAAAAAAA AAAAAAAAAA AAAAAAAAAAAA A is considered to be friendly:

 FAIL  src/address/Address.spec.ts
  Address
    ✓ should parse addresses in various forms (3 ms)
    ✓ should serialize to friendly form
    ✓ should implement equals
    ✕ should throw if address is invalid (8 ms)

  ● Address › should throw if address is invalid

    expect(received).toBe(expected) // Object.is equality

    Expected: false
    Received: true

      94 |             Address.parseFriendly('!@#$%^&*AAAAAAAAAAAAAA AAAAAAAAAA AAAAAAAAAAAA A')
      95 |         }).toThrowError('Unknown address type');
    > 96 |         expect(Address.isFriendly('!@#$%^&*AAAAAAAAAAAAAA AAAAAAAAAA AAAAAAAAAAAA A')).toBe(false)

@kolpav kolpav changed the title Anchor regex in isFriendly Regex in isFriendly should be anchored Feb 23, 2025
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.

1 participant