-
Notifications
You must be signed in to change notification settings - Fork 27k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: normalize-asset-prefix
adding leading slash when URL assetPrefix
is provided
#68518
Merged
devjiwonchoi
merged 3 commits into
canary
from
08-05-fix_normalize_asset_prefix_for_socket_if_start_with_http
Aug 7, 2024
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
packages/next/src/shared/lib/normalized-asset-prefix.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { normalizedAssetPrefix } from './normalized-asset-prefix' | ||
|
||
describe('normalizedAssetPrefix', () => { | ||
it('should return an empty string when assetPrefix is nullish', () => { | ||
expect(normalizedAssetPrefix(undefined)).toBe('') | ||
}) | ||
|
||
it('should return an empty string when assetPrefix is an empty string', () => { | ||
expect(normalizedAssetPrefix('')).toBe('') | ||
}) | ||
|
||
it('should return an empty string when assetPrefix is a single slash', () => { | ||
expect(normalizedAssetPrefix('/')).toBe('') | ||
}) | ||
|
||
// we expect an empty string because it could be an unnecessary trailing slash | ||
it('should remove leading slash(es) when assetPrefix has more than one', () => { | ||
expect(normalizedAssetPrefix('///path/to/asset')).toBe('/path/to/asset') | ||
}) | ||
|
||
it('should not remove the leading slash when assetPrefix has only one', () => { | ||
expect(normalizedAssetPrefix('/path/to/asset')).toBe('/path/to/asset') | ||
}) | ||
|
||
it('should add a leading slash when assetPrefix is missing one', () => { | ||
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' | ||
) | ||
|
||
expect(normalizedAssetPrefix('https://example.com/path/to/asset')).toBe( | ||
'example.com/path/to/asset' | ||
) | ||
}) | ||
}) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eps1lon At first, it was expected to remove the protocol because #67983 added this function to handle at
getSocketUrl
, and it simply added thews
protocol to the output.next.js/packages/next/src/client/components/react-dev-overlay/internal/helpers/get-socket-url.ts
Lines 19 to 23 in cc7b9e6