mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2025-10-26 11:27:18 +00:00
Updates for code review
This commit is contained in:
parent
bf11113200
commit
b59ff8ce39
@ -355,7 +355,23 @@ describe('sortIp', () => {
|
||||
describe('sortAddress', () => {
|
||||
testBaseSortFunction(sortAddress);
|
||||
|
||||
describe('mixed_withString', () => {
|
||||
describe('domain_names_sorting', () => {
|
||||
test('widcard before other names', () => {
|
||||
const arr = [
|
||||
'home.fritz.box',
|
||||
'*.home.fritz.box',
|
||||
'adguard-home.fritz.box'
|
||||
]
|
||||
|
||||
const sortedArr = [
|
||||
'*.home.fritz.box',
|
||||
'adguard-home.fritz.box',
|
||||
'home.fritz.box'
|
||||
];
|
||||
|
||||
expect(arr.sort(sortAddress)).toStrictEqual(sortedArr);
|
||||
})
|
||||
|
||||
test('only non-ip strings', () => {
|
||||
const arr = [
|
||||
'fritz.box',
|
||||
@ -392,7 +408,7 @@ describe('sortAddress', () => {
|
||||
expect(arr.sort(sortAddress)).toStrictEqual(sortedArr);
|
||||
});
|
||||
|
||||
test('ipv4, ipv6 in short and long forms and cidr', () => {
|
||||
test('ipv4, ipv6 in short and long forms and cidr, and a few domain names', () => {
|
||||
const arr = [
|
||||
'2001:db8:11a3:9d7:0:0:0:1/32',
|
||||
'192.168.1.2',
|
||||
|
||||
@ -793,9 +793,7 @@ const getAddressesComparisonChunks = (address: string, allowOnlyIpAddresses: boo
|
||||
}
|
||||
catch (e) {
|
||||
if (allowOnlyIpAddresses) {
|
||||
// Rethrowing the exception if only IP addresses and CIDRs are allowed.
|
||||
// This is to ensure exactly same behavior as in the original code.
|
||||
throw e
|
||||
throw new Error(`Invalid address: ${address}. Only IP addresses and CIDRs are allowed.`, { cause: e });
|
||||
}
|
||||
|
||||
return [NOT_IP_ADDRESS, address];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user