Skip to content
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

Sorting URLs improvements #6061

Open
3 tasks done
Fufs opened this issue Jul 31, 2023 · 0 comments
Open
3 tasks done

Sorting URLs improvements #6061

Fufs opened this issue Jul 31, 2023 · 0 comments

Comments

@Fufs
Copy link

Fufs commented Jul 31, 2023

Prerequisites

  • I have checked the Wiki and Discussions and found no answer

  • I have searched other issues and found no duplicates

  • 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))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants