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

No way to override URL instance comparison? #121

Closed
eaton opened this issue May 16, 2024 · 4 comments · Fixed by #128
Closed

No way to override URL instance comparison? #121

eaton opened this issue May 16, 2024 · 4 comments · Fixed by #128
Assignees
Labels

Comments

@eaton
Copy link

eaton commented May 16, 2024

Not sure if I'm missing something in the internals of createCustomEqual(), but it seems that URL instances in particular are always treated as unequal. Because internally getTag() returns [object URL], areObjectsEqual() is never called and custom equality functions never even get called.

Is there any way around this? Has passing in custom quality functions on a per-tag basis to handle special cases considered?

@planttheidea
Copy link
Owner

Is there a repri that you can make for this? A simple test would allow me to build a targeted solution.

@planttheidea planttheidea self-assigned this Sep 14, 2024
@planttheidea
Copy link
Owner

Rereading this with fresh eyes, I can just add this in, since it seems to be expected behavior to use object comparison.

@planttheidea
Copy link
Owner

Comparison as a standard object is a no-go because the properties on the URL object are not enumerable, so nothing but false positives since it is seen as an empty object. However, like RegExp the properties are known and primitives, so a fast targeted comparator was easy to build.

@planttheidea
Copy link
Owner

Has been resolved as-of 5.1.0, as you can use the new areUrlsEqual method in a custom equality config.

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

Successfully merging a pull request may close this issue.

2 participants