Skip to content

Handle non-standard second-level domains in getRootDomain#37

Merged
ormidales merged 2 commits into1.0.2from
copilot/fix-second-level-domain-parser
Feb 16, 2026
Merged

Handle non-standard second-level domains in getRootDomain#37
ormidales merged 2 commits into1.0.2from
copilot/fix-second-level-domain-parser

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 16, 2026

getRootDomain relied on a narrow hardcoded second-level suffix set, which caused incorrect root extraction for domains like mon-site.asso.fr (returned as asso.fr). This impacted whitelist targeting and redirect-domain comparison for ccTLD patterns outside the original list.

  • Domain parsing update (utils.js)

    • Expanded secondLevelSuffixes used by getRootDomain to recognize additional second-level labels used with 2-letter TLDs:
      • added: asso, gouv, nom
    • Existing behavior for already-supported patterns (e.g. co.uk, com.au) remains unchanged.
  • Behavioral impact

    • Root domain extraction now preserves expected registrable domains for additional ccTLD forms, including the reported .asso.fr case.
const secondLevelSuffixes = new Set([
  "ac", "asso", "co", "com", "edu", "gov", "gouv", "net", "nom", "org"
]);
Original prompt

This section details on the original issue you should resolve

<issue_title>Défaillance du parseur sur les domaines de second niveau non standards</issue_title>
<issue_description>## Contexte
La fonction getRootDomain centralise l'extraction du domaine racine pour la mise en liste blanche et la comparaison des redirections.

Problème

La constante secondLevelSuffixes est codée en dur avec une liste très restreinte (ac, co, com, edu, gov, net, org). Les domaines utilisant d'autres suffixes (comme .asso.fr ou .com.au) sont mal découpés.

Scénario de Reproduction

  1. Naviguer sur mon-site.asso.fr.
  2. Ouvrir la popup de l'extension.
  3. Observer le domaine proposé pour l'ajout.

Comportement Attendu

Le système doit extraire mon-site.asso.fr et non asso.fr.

Pistes Techniques

Remplacer l'approche par liste statique restrictive par l'intégration d'une librairie légère gérant la Public Suffix List (PSL), ou élargir la liste des suffixes reconnus dans utils.js.

Environnement

Toutes plateformes.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: ormidales <46538211+ormidales@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix parser failure for non-standard second-level domains Handle non-standard second-level domains in getRootDomain Feb 16, 2026
Copilot AI requested a review from ormidales February 16, 2026 14:34
@ormidales ormidales added this to the v1.0.2 milestone Feb 16, 2026
@ormidales ormidales marked this pull request as ready for review February 16, 2026 14:38
Copilot AI review requested due to automatic review settings February 16, 2026 14:38
@ormidales ormidales merged commit 83d2e58 into 1.0.2 Feb 16, 2026
@ormidales ormidales deleted the copilot/fix-second-level-domain-parser branch February 16, 2026 14:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates getRootDomain’s ccTLD handling to correctly extract registrable domains for additional second-level domain patterns (e.g., .asso.fr), improving whitelist targeting and redirect-domain comparisons across more real-world ccTLD structures.

Changes:

  • Expanded secondLevelSuffixes in utils.js to include asso, gouv, and nom.
  • Preserved existing behavior for previously supported patterns (e.g., co.uk, com.au).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread utils.js
}

const secondLevelSuffixes = new Set(["ac", "co", "com", "edu", "gov", "net", "org"]);
const secondLevelSuffixes = new Set(["ac", "asso", "co", "com", "edu", "gov", "gouv", "net", "nom", "org"]);
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

secondLevelSuffixes is instantiated on every getRootDomain call. Consider hoisting it to a module-level constant (e.g., const SECOND_LEVEL_SUFFIXES = new Set([...])) to avoid repeated allocations and make future updates easier.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Défaillance du parseur sur les domaines de second niveau non standards

3 participants