-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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}`); | |
} |
'*.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.
/windsurf-review |
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".
}; | ||
|
||
const getAsElementForSorting = (item: any) => { |
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 function name getAsElementForSorting
is misleading since it doesn't return an element for sorting but rather converts the input to a string. Consider renaming to something like getStringForSorting
or normalizeItemToString
to better reflect its purpose.
@@ -4,7 +4,7 @@ import React, { Component } from 'react'; | |||
import ReactTable from 'react-table'; | |||
import { withTranslation } from 'react-i18next'; | |||
|
|||
import { sortIp } from '../../../helpers/helpers'; | |||
import { sortAddress, sortAddressByTld } from '../../../helpers/helpers'; |
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 sortAddressByTld
function is imported but not used in this file. Consider removing the unused import.
return "" + item; | ||
} |
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.
Missing semicolon at the end of the function.
return "" + item; | |
} | |
return "" + item; | |
} |
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.