Skip to content

Report CdnPreconnect for cdn.shopify.com without a path - #1366

Open
RaphaelFakhri wants to merge 1 commit into
Shopify:mainfrom
RaphaelFakhri:fix/cdn-preconnect-bare-origin
Open

RaphaelFakhri wants to merge 1 commit into
Shopify:mainfrom
RaphaelFakhri:fix/cdn-preconnect-bare-origin

Conversation

@RaphaelFakhri

Copy link
Copy Markdown

What are you adding in this PR?

Fixes #1365

CdnPreconnect matched the href with .+cdn.shopify.com.+. The pattern needs a character after the host, so <link rel="preconnect" href="https://cdn.shopify.com" crossorigin> and href="//cdn.shopify.com" were never reported. The unescaped, unanchored pattern also reported other hosts, such as https://example.com/cdn.shopify.com.html.

The check now matches (https?:)?//cdn\.shopify\.com(/\S*)?, so it reports the Shopify CDN origin with or without a path, and only when it is the host.

What's next? Any followup issues?

None.

What did you learn?

The Ruby version of this check reported any href that contained cdn.shopify.com, so the bare origin case regressed in the port.

Tophatting

  • New spec cases in packages/theme-check-common/src/checks/cdn-preconnect/index.spec.ts cover the bare origin, the protocol-relative origin, and a non-Shopify host. They fail on main (2 failed, 3 passed) and pass with this change (5 passed).

  • npx vitest run packages/theme-check-common passes (5367 tests).

  • I added screenshots of the changes (before and after the changes if applicable)

Before you deploy

  • I included a patch bump changeset

@RaphaelFakhri
RaphaelFakhri requested a review from a team as a code owner October 22, 2026 12:03

This branch has not been deployed

No deployments
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.

CdnPreconnect misses href="https://cdn.shopify.com" without a trailing path

1 participant