AdguardTeam / AdguardTeam/AdGuardHome
Sorting URLs improvements
- Linguagem predominante
- TypeScript
- Estrelas
- 36.9k
- Forks
- 2.5k
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
### Prerequisites
- [X] I have checked the [Wiki](https://github.com/AdguardTeam/AdGuardHome/wiki) and [Discussions](https://github.com/AdguardTeam/AdGuardHome/discussions) and found no answer
- [X] I have searched other issues and found no duplicates
- [X] I want to request a feature or enhancement and not ask a question
### The problem
Currently when sorting URLs (say in the DNS rewrites tab), the sorting is done from left to right. This is quite inconvinient as a list of following urls:
* a.tld
* b.tld
* a.b.tld
* b.a.tld
* a.b.a.tld
Will be sorted as follows:
- a.b.a.tld
- a.b.tld
- a.tld
- b.a.tld
- b.tld
A much better way of sorting would result in the following list:
- a.tld
- b.a.tld
- a.b.a.tld
- b.tld
- a.b.tld
### Proposed solution
1. Split the strings by the period symbol ("a.b.a.tld" => ["a", "b", "a", "tld"])
2. Reverse the list (["a", "b", "a", "tld"] => ["tld", "a", "b", "a"])
3. Join the elements together with a period (["tld", "a", "b", "a"] => tld.a.b.a)
4. Sort with those keys
5. Reverse the steps before displaying the sorted list
This could probably be optimized but that's the general idea.
### Alternatives considered and additional information
It is worth noting that IPs should not be sorted this way. Therefore, if a field can contain both IPs and domains, we have to check first if the contents of a cell are and ip address or not (for example with this regex `^((\d|1?[1-9]\d|2[0-4]\d|25[0-5])\.){3}(\d|1?[1-9]\d|2[0-4]\d|25[0-5])$` (have not tested it))
Guia de contribuição
Avaliação
Esta issue ainda não foi avaliada.