Skip to content

Conversation

@iclectic
Copy link
Contributor

@iclectic iclectic commented Nov 16, 2025

Description

  • This update removes repeated definitions of the functions matchHostname, matchPathname, matchProtocol, matchPort and matchPattern, which are already available in the astrojs/internal-helpers/remote package.
  • By switching to the shared helpers, the change removes an existing build warning about unused external imports and reduces duplicated logic across the codebase.

Changes

  • Deleted 54 lines of duplicate helper function definitions from packages/integrations/cloudflare/src/utils/assets.ts.
  • Added imports for matchHostname and matchPattern from astrojs/internal-helpers/remote.
  • Added a missing type import for AstroConfig from astro.
  • Maintained existing behaviour. The isRemoteAllowed function operates exactly as before, now relying on the shared implementations.
  • Reduced the file size from 77 lines to 23 lines.

Before:

  • File contained five locally implemented helper functions.
  • Build warning appeared: matchHostname, matchPathname, matchOther and matchProtocol were being imported from an external module.

After:

  • File now imports these helpers directly from the official package.
  • No build warnings.
  • The helpers now have a single, consistent source.

Testing

  • Successfully built the entire project using pnpm run build.
  • Successfully built the internal-helpers package (packages/internal-helpers).
  • No TypeScript errors.
  • Build warning removed.
  • All 31 build tasks completed without issues.
  • No new tests added, as this is purely a refactor. The existing behaviour is preserved because the same implementations from astrojs/internal-helpers/remote are now used instead of local duplicates.

Documentation
No documentation updates are required because this is an internal refactor that:

  • Does not alter any public API.
  • Does not change any user-facing behaviour.
  • Does not modify how the Cloudflare adapter functions.
  • Only removes duplicated logic and consolidates it into a shared package.

Removes the repeated definitions of matchHostname, matchPathname,
matchProtocol, matchPort and matchPattern that are already provided by
the @astrojs/internal-helpers/remote package.

This resolves the build warning about unused external imports and avoids
maintaining the same logic in multiple places by relying on the shared
helpers.

Closes withastro#14752
@changeset-bot
Copy link

changeset-bot bot commented Nov 16, 2025

🦋 Changeset detected

Latest commit: 88d3e0c

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: integration Related to any renderer integration (scope) label Nov 16, 2025
@iclectic iclectic changed the title Fix/cloudflare remove duplicate functions fix(cloudflare): eliminate duplicate import warnings during build Nov 16, 2025
@florian-lefebvre florian-lefebvre added the pr preview Apply this label to a PR to generate a preview release label Nov 24, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 24, 2025

npm i https://pkg.pr.new/astro@14777
npm i https://pkg.pr.new/@astrojs/cloudflare@14777
npm i https://pkg.pr.new/@astrojs/vercel@14777

commit: 0a09855

Copy link
Member

@florian-lefebvre florian-lefebvre left a comment

Choose a reason for hiding this comment

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

Thanks! This doesn't solve the linked issue but it's a good improvement

@florian-lefebvre florian-lefebvre merged commit 9720b70 into withastro:main Nov 24, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: integration Related to any renderer integration (scope) pr preview Apply this label to a PR to generate a preview release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants