Skip to content

Commit

Permalink
Modify asset proxy field to accept just host strings
Browse files Browse the repository at this point in the history
  • Loading branch information
cwli24 committed Oct 4, 2023
1 parent 70a896b commit 41c6b21
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/loaders/configure/configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function configure (agentIdentifier, opts = {}, loaderType, forceDrain) {
if (!alreadySetOnce) {
alreadySetOnce = true
if (updatedInit.proxy.assets) {
redefinePublicPath(updatedInit.proxy.assets + '/') // much like the info.beacon & init.proxy.beacon, this input should not end in a slash, but one is needed for webpack concat
redefinePublicPath(updatedInit.proxy.assets)
internalTrafficList.push(updatedInit.proxy.assets)
}
if (updatedInit.proxy.beacon) internalTrafficList.push(updatedInit.proxy.beacon)
Expand Down
9 changes: 6 additions & 3 deletions src/loaders/configure/public-path.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// Set the default CDN or remote for fetching the assets; NPM shouldn't change this var.

export const redefinePublicPath = (url) => {
// There's no URL validation here, so caller should check arg if need be.
__webpack_public_path__ = url // eslint-disable-line
export const redefinePublicPath = (urlString) => {
const isOrigin = urlString.startsWith('http')
// Input is not expected to end in a slash, but webpack concats as-is, so one is inserted.
urlString += '/'
// If there's no existing HTTP scheme, the secure protocol is prepended by default.
__webpack_public_path__ = isOrigin ? urlString : 'https://' + urlString // eslint-disable-line
}

0 comments on commit 41c6b21

Please sign in to comment.