From 63257931bccbd74638cb0a96241c7d9c87457b8e Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Sat, 9 Nov 2019 15:07:39 +0800 Subject: [PATCH] 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. --- packages/@vue/cli-service/__tests__/Service.spec.js | 10 ++++++++++ packages/@vue/cli-service/lib/Service.js | 5 +---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/@vue/cli-service/__tests__/Service.spec.js b/packages/@vue/cli-service/__tests__/Service.spec.js index e11de4658a..f145090c92 100644 --- a/packages/@vue/cli-service/__tests__/Service.spec.js +++ b/packages/@vue/cli-service/__tests__/Service.spec.js @@ -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: { diff --git a/packages/@vue/cli-service/lib/Service.js b/packages/@vue/cli-service/lib/Service.js index 525a00faac..e055b0a2fb 100644 --- a/packages/@vue/cli-service/lib/Service.js +++ b/packages/@vue/cli-service/lib/Service.js @@ -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/') } }