Skip to content

Commit 6325793

Browse files
authored
fix: don't prepend publicPath with slash (#4816)
fixes #3338 fixes #4184 Actually I don't know why the slash was added in the first place, seems extraneous to me.
1 parent 1124b62 commit 6325793

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

packages/@vue/cli-service/__tests__/Service.spec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,16 @@ test('normalize publicPath when relative', () => {
104104
expect(service.projectOptions.publicPath).toBe('foo/bar/')
105105
})
106106

107+
test('allow custom protocol in publicPath', () => {
108+
mockPkg({
109+
vue: {
110+
publicPath: 'customprotocol://foo/bar'
111+
}
112+
})
113+
const service = createMockService()
114+
expect(service.projectOptions.publicPath).toBe('customprotocol://foo/bar/')
115+
})
116+
107117
test('keep publicPath when empty', () => {
108118
mockPkg({
109119
vue: {

packages/@vue/cli-service/lib/Service.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -395,11 +395,8 @@ module.exports = class Service {
395395
}
396396

397397
function ensureSlash (config, key) {
398-
let val = config[key]
398+
const val = config[key]
399399
if (typeof val === 'string') {
400-
if (!/^https?:/.test(val)) {
401-
val = val.replace(/^([^/.])/, '/$1')
402-
}
403400
config[key] = val.replace(/([^/])$/, '$1/')
404401
}
405402
}

0 commit comments

Comments
 (0)