-
Notifications
You must be signed in to change notification settings - Fork 2k
Fix for #6320 #7878
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
base: master
Are you sure you want to change the base?
Fix for #6320 #7878
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 To request another review, post a new comment with "/windsurf-review".
client/src/helpers/helpers.tsx
Outdated
if (allowOnlyIpAddresses) { | ||
throw e | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding more context to the error when throwing in strict mode (allowOnlyIpAddresses=true). This would make debugging easier.
if (allowOnlyIpAddresses) { | |
throw e | |
} | |
if (allowOnlyIpAddresses) { | |
throw new Error(`Invalid IP address or CIDR: ${address}`); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added more comment around the throw e
to explain why this is the exactly desired behaviour.
'*.home.fritz.net', | ||
'adguard-home.fritz.box', | ||
'foo.bar', | ||
'fritz.box', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The wildcard pattern '*.home.fritz.net' is placed before other domain names in the sorted result, which seems inconsistent with the alphabetical sorting of other non-IP strings. Consider either sorting wildcard patterns alphabetically along with other domain names or documenting the special ordering rule if this is intentional behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is expected order, consistent with the regular string comparison and what is observed in the application in many places.
Closes #6320
This introduces additional sorting function -
sortAddress
- that extends the behaviour of existingsortIp
. There were two options effectively hereThe second approach was selected. The unit tests for the previous implementation pass 100%, there is a new set of tests for the new function as well.
I also cleaned up a bit the code around sorting, added some additional type safety and removed a need for es-lint overrides.