Skip to content

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Fix for #6320 #7878

wants to merge 2 commits into from

Conversation

grogi
Copy link

@grogi grogi commented Jun 14, 2025

Closes #6320

This introduces additional sorting function - sortAddress - that extends the behaviour of existing sortIp. There were two options effectively here

  • expand the sortIp and (although unlikely) potentially modify the existing behaviour
  • create a new sorting function.

The 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.

image

I also cleaned up a bit the code around sorting, added some additional type safety and removed a need for es-lint overrides.

Copy link

@windsurf-bot windsurf-bot bot left a 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".

Comment on lines 795 to 797
if (allowOnlyIpAddresses) {
throw e
}
Copy link

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.

Suggested change
if (allowOnlyIpAddresses) {
throw e
}
if (allowOnlyIpAddresses) {
throw new Error(`Invalid IP address or CIDR: ${address}`);
}

Copy link
Author

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.

Comment on lines +445 to +448
'*.home.fritz.net',
'adguard-home.fritz.box',
'foo.bar',
'fritz.box',
Copy link

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.

Copy link
Author

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.

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.

Sorting by Answer column, in DNS Rewrites tab, doesn't work correctly if CNAME and IP addresses present.
1 participant