Skip to content

Commit

Permalink
fix: don't prepend publicPath with slash (vuejs#4816)
Browse files Browse the repository at this point in the history
fixes vuejs#3338
fixes vuejs#4184

Actually I don't know why the slash was added in the first place, seems
extraneous to me.
  • Loading branch information
haoqunjiang authored Nov 9, 2019
1 parent 1124b62 commit 6325793
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
10 changes: 10 additions & 0 deletions packages/@vue/cli-service/__tests__/Service.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ test('normalize publicPath when relative', () => {
expect(service.projectOptions.publicPath).toBe('foo/bar/')
})

test('allow custom protocol in publicPath', () => {
mockPkg({
vue: {
publicPath: 'customprotocol://foo/bar'
}
})
const service = createMockService()
expect(service.projectOptions.publicPath).toBe('customprotocol://foo/bar/')
})

test('keep publicPath when empty', () => {
mockPkg({
vue: {
Expand Down
5 changes: 1 addition & 4 deletions packages/@vue/cli-service/lib/Service.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,11 +395,8 @@ module.exports = class Service {
}

function ensureSlash (config, key) {
let val = config[key]
const val = config[key]
if (typeof val === 'string') {
if (!/^https?:/.test(val)) {
val = val.replace(/^([^/.])/, '/$1')
}
config[key] = val.replace(/([^/])$/, '$1/')
}
}
Expand Down

0 comments on commit 6325793

Please sign in to comment.