Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
test: normalize-asset-prefix should return url if is url
  • Loading branch information
devjiwonchoi committed Aug 6, 2024
commit 240f468e52b004436d94f8bedbf67868a8cdabe6
17 changes: 11 additions & 6 deletions packages/next/src/shared/lib/normalized-asset-prefix.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,19 @@ describe('normalizedAssetPrefix', () => {
expect(normalizedAssetPrefix('path/to/asset')).toBe('/path/to/asset')
})

it('should return a URL without protocol when assetPrefix is a URL', () => {
// TODO: this is for comparison, remove this before PR merge
expect(normalizedAssetPrefix('https://example.com/path/to/asset')).not.toBe(
'/https://example.com/path/to/asset'
)
it('should remove all trailing slash(es) when assetPrefix has one', () => {
expect(normalizedAssetPrefix('/path/to/asset///')).toBe('/path/to/asset')
})

it('should return the URL when assetPrefix is a URL', () => {
expect(normalizedAssetPrefix('https://example.com/path/to/asset')).toBe(
'example.com/path/to/asset'
'https://example.com/path/to/asset'
)
})

it('should not leave a trailing slash when assetPrefix is a URL with no pathname', () => {
expect(normalizedAssetPrefix('https://example.com')).toBe(
'https://example.com'
)
})
})