Skip to content

fix(shopping): recover merchant_domain from scheme-less merchant URLs - #888

Merged
gkhngyk merged 1 commit into
ansvisor:mainfrom
shahzainshafique:fix/shopping-merchant-domain-scheme-less
Oct 3, 2026
Merged

gkhngyk merged 1 commit into
ansvisor:mainfrom
shahzainshafique:fix/shopping-merchant-domain-scheme-less

Conversation

@shahzainshafique

Copy link
Copy Markdown
Contributor

Summary

shopping-cards.js had its own extractHostname that returned null whenever new URL() threw — including on a merchant link with no scheme such as shop.example.com/p/1, which does occur in AI answers. Such a card was stored with merchant_domain: null and dropped out of every merchant grouping.

Delete the local copy and use the shared extractDomain from citation-rows, which does the same www-strip/lowercase normalization but recovers the host from scheme-less URLs via a regex fallback. One source of truth, so the two can't drift. Adds a parsePerplexityCard test for the scheme-less case.

Related issue

Closes #874

Type of change

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

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

shopping-cards.js had its own extractHostname that returned null whenever
new URL() threw — including on a merchant link with no scheme such as
shop.example.com/p/1, which does occur in AI answers. Such a card was
stored with merchant_domain: null and dropped out of every merchant
grouping.

Delete the local copy and use the shared extractDomain from citation-rows,
which does the same www-strip/lowercase normalization but recovers the host
from scheme-less URLs via a regex fallback. One source of truth, so the two
can't drift. Adds a parsePerplexityCard test for the scheme-less case.

Closes ansvisor#874

@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 @shahzainshafique — exactly the fix we had in mind, and nice test.

@gkhngyk
gkhngyk merged commit 129223b into ansvisor:main Oct 3, 2026
6 checks passed
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.

bug: shopping cards lose merchant_domain when the merchant URL has no scheme

2 participants