Skip to content

Commit

Permalink
fix: normalize asset prefix for socket if start with http
Browse files Browse the repository at this point in the history
  • Loading branch information
devjiwonchoi committed Aug 5, 2024
1 parent c74f3f5 commit 1182627
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function getSocketUrl(assetPrefix: string | undefined): string {

// if original assetPrefix is a full URL with protocol
// we just update to use the correct `ws` protocol
if (assetPrefix?.replace(/^\/+/, '').includes('://')) {
if (assetPrefix?.startsWith('http')) {
return `${protocol}://${prefix}`
}

Expand Down
5 changes: 3 additions & 2 deletions packages/next/src/shared/lib/normalized-asset-prefix.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
export function normalizedAssetPrefix(assetPrefix: string | undefined): string {
const escapedAssetPrefix = assetPrefix?.replace(/^\/+/, '') || false

// assetPrefix as a url
if (escapedAssetPrefix && escapedAssetPrefix.startsWith('://')) {
if (escapedAssetPrefix && escapedAssetPrefix.startsWith('http')) {
// remove protocol for socket url
// https://example.com/path/to/asset -> example.com/path/to/asset
return escapedAssetPrefix.split('://', 2)[1]
}

Expand Down

0 comments on commit 1182627

Please sign in to comment.