Skip to content

Conversation

@nd0ut
Copy link
Member

@nd0ut nd0ut commented Jul 9, 2025

Description

Checklist

@nd0ut nd0ut requested a review from egordidenko July 9, 2025 20:32
@nd0ut nd0ut force-pushed the feat/add-is-prefixed-cdn-base-util branch 2 times, most recently from f2a9d10 to b25e176 Compare July 9, 2025 20:45
@egordidenko egordidenko requested a review from Copilot July 10, 2025 05:31

This comment was marked as outdated.

@egordidenko egordidenko requested a review from Copilot July 10, 2025 05:45
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds a new helper to determine whether a given CDN base URL includes a specified prefix subdomain, and exposes it across sync, async, and main package entries.

  • Implements isPrefixedCdnBase in common/
  • Exports the helper in async/index.ts, sync/index.ts, and package root index.ts
  • Provides unit tests covering typical and invalid URL cases

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/cname-prefix/src/common/isPrefixedCdnBase.ts Added isPrefixedCdnBase helper implementation
packages/cname-prefix/src/common/isPrefixedCdnBase.test.ts Introduced unit tests for the new helper
packages/cname-prefix/src/async/index.ts Re-exported helper in the async entry point
packages/cname-prefix/src/sync/index.ts Re-exported helper in the sync entry point
packages/cname-prefix/src/index.ts Exposed helper in main package entry
Comments suppressed due to low confidence (3)

packages/cname-prefix/src/common/isPrefixedCdnBase.ts:1

  • [nitpick] Consider adding a JSDoc comment above this function to explain its purpose, parameters, return value, and edge-case behavior for better readability and maintainability.
export const isPrefixedCdnBase = (cdnBase: string, prefixCdnBase: string) => {

packages/cname-prefix/src/common/isPrefixedCdnBase.test.ts:34

  • Add a test for multi-level subdomains (e.g. 'https://a.b.ucarecd.net', 'https://ucarecd.net') to verify the helper handles deeper prefix chains as intended.
})

packages/cname-prefix/src/index.ts:3

  • [nitpick] Remember to update the package README and CHANGELOG to document the new isPrefixedCdnBase helper as part of the public API.
export { isPrefixedCdnBase } from './common/isPrefixedCdnBase'

Comment on lines 7 to 13
const cdnBaseHostnameParts = cdnBaseHostname.split('.')
if (cdnBaseHostnameParts.length !== 3) {
return false
}
const [, sld, tld] = cdnBaseHostnameParts
const cdnBaseHostnameWithoutPrefix = `${sld}.${tld}`
return prefixCdnBaseUrl.hostname === cdnBaseHostnameWithoutPrefix
Copy link

Copilot AI Jul 10, 2025

Choose a reason for hiding this comment

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

The helper currently only handles exactly three hostname parts, which will fail for multi-level subdomains. Consider using cdnBaseUrl.hostname.endsWith(.${prefixCdnBaseUrl.hostname}) to simplify the logic and support arbitrary subdomain depths.

Suggested change
const cdnBaseHostnameParts = cdnBaseHostname.split('.')
if (cdnBaseHostnameParts.length !== 3) {
return false
}
const [, sld, tld] = cdnBaseHostnameParts
const cdnBaseHostnameWithoutPrefix = `${sld}.${tld}`
return prefixCdnBaseUrl.hostname === cdnBaseHostnameWithoutPrefix
return cdnBaseHostname.endsWith(`.${prefixCdnBaseUrl.hostname}`)

Copilot uses AI. Check for mistakes.
@nd0ut nd0ut force-pushed the feat/add-is-prefixed-cdn-base-util branch from b25e176 to c311b5b Compare July 10, 2025 07:23
@nd0ut nd0ut merged commit 09d2a8c into master Jul 10, 2025
4 checks passed
@nd0ut nd0ut deleted the feat/add-is-prefixed-cdn-base-util branch July 10, 2025 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants