Skip to content

feat(shopping): classify merchant destinations and listing IDs - #1242

Merged
gkhngyk merged 10 commits into
ansvisor:mainfrom
knockknock10:feature/merchant-detection-1186
Oct 20, 2026
Merged

gkhngyk merged 10 commits into
ansvisor:mainfrom
knockknock10:feature/merchant-detection-1186

Conversation

@knockknock10

Copy link
Copy Markdown
Contributor

Summary

  • Add a pure classifyMerchant(merchantUrl, { brandDomains }) helper that returns kind, marketplace, and listingId.
  • Add a JSON marketplace registry with country domains for Amazon/eBay and hosts for Walmart, Etsy, AliExpress, Temu, Trendyol and Hepsiburada.
  • Resolve only known affiliate redirect hosts and their configured destination parameters (s.click.aliexpress.com?dl_target_url=…, `goto.walmart.com?u=…)); do not follow arbitrary redirect links.
  • Classify exact brand domains and their subdomains as own store, known marketplace hosts as marketplaces, and other or malformed URLs as resellers.
  • Extract Amazon ASINs, eBay item IDs, Walmart item IDs and Etsy listing IDs, ignoring tracking query parameters.
  • Add fixture tests for country domains, subdomains, affiliate redirects, own-store matching, listing IDs, unknown hosts and malformed input.

Related issue

Closes #1186

Type of change

  • feat — New feature
  • test — Adding or updating tests
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature

Validation

  • npm test from server/ — 1,848 tests passed (including 30 new merchant-detection cases)
  • npm run lint from server/
  • npm run format:check from server/
  • Branch follows the feature/ naming convention
  • Commits follow Conventional Commits
  • Changes are focused — 3 files only

Copilot AI balanced review requested due to automatic review settings October 20, 2026 04:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, a clean library for #1186. It makes no network calls, fails safely on bad input, and the listing-ID rules match the issue. Two fixes before merge, since the classifier's answers are the point:

  1. Relative redirect targets are read as hosts. redirectTarget calls parseHttpUrl before its relative branch. parseHttpUrl('/ip/Blue-Coat/123') retries as https:///ip/..., whose hostname is ip, so goto.walmart.com/?u=%2Fip%2F… comes out as reseller. u=foo becomes host foo the same way. For redirect parameters, check for a leading / first and accept only explicit http(s):// values; otherwise fall back to the redirect host's marketplace. Please add fixtures for both cases.
  2. Host list gaps in merchant-marketplaces.json. All of these come out as reseller today:
    • Amazon Belgium is amazon.com.be; the list has amazon.be.
    • amazon.co.za, ebay.at and ebay.ch are missing.
    • So are the short-link hosts amzn.to, amzn.eu, a.co and ebay.us.

Smaller:

  • isOwnDomain re-implements ownDomainMatcher (server/src/lib/response-parser.js). Reusing it keeps "own" the same as on Citations.
  • Add a fixture for Amazon's /<slug>/dp/<ASIN>/ref=… URLs.

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, all four points are addressed: relative and non-URL redirect values, the missing country and short-link hosts, the shared own-domain matcher, and the slugged ASIN fixture. Tested on top of main with #1239–#1241 and #1131: server 1,897 tests pass, and lint and Prettier are clean.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(shopping): classify where each product card sends shoppers: own store, marketplace or reseller

3 participants