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/') } }