Skip to content

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

Closed

Description

@gkhngyk

Description

server/src/lib/shopping-cards.js has its own private extractHostname (line 167), used for merchant_domain on every card type (lines 227, 253, 299, 349). It returns null whenever new URL() throws — for example on a merchant URL without a scheme such as shop.example.com/p/1.

The shared helper extractDomain in server/src/lib/citation-rows.js (line 32) does the same normalization but recovers the host from scheme-less URLs with a regex fallback, because such URLs do occur in AI answers.

The result is that a shopping card with a scheme-less merchant link is stored with merchant_domain: null and drops out of any merchant grouping.

Expected behavior

merchant_domain is shop.example.com for shop.example.com/p/1, the same as for https://shop.example.com/p/1.

Suggested fix

Import extractDomain from citation-rows.js and delete the local copy. Add a case to server/src/lib/shopping-cards.test.js with a scheme-less merchant URL.

Run yarn test from server/ before opening the PR — see CONTRIBUTING.md.

Activity

  1. added
    bug
    good first issue
    help wanted
    on Oct 3, 2026
  2. shahzainshafique commented on Oct 3, 2026

    @shahzainshafique
    Contributor

    Hi @gkhngyk,

    I've worked on a fix for this issue. The PR #888 is created and linked with this issue. Please review.

  3. added a commit that references this issue on Oct 15, 2026
    129223b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggood first issuehelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions