fix(compiler-sfc): support transforming asset urls with full base url. (#2477)

This commit is contained in:
Joel Denning
2020-12-04 16:20:25 -07:00
committed by GitHub
parent 3867bb4c14
commit db786b1afe
4 changed files with 74 additions and 5 deletions

View File

@@ -94,4 +94,36 @@ describe('compiler sfc: transform asset url', () => {
// should not remove it
expect(code).toMatch(`"xlink:href": "#myCircle"`)
})
test('should allow for full base URLs, with paths', () => {
const { code } = compileWithAssetUrls(`<img src="./logo.png" />`, {
base: 'http://localhost:3000/src/'
})
expect(code).toMatchSnapshot()
})
test('should allow for full base URLs, without paths', () => {
const { code } = compileWithAssetUrls(`<img src="./logo.png" />`, {
base: 'http://localhost:3000'
})
expect(code).toMatchSnapshot()
})
test('should allow for full base URLs, without port', () => {
const { code } = compileWithAssetUrls(`<img src="./logo.png" />`, {
base: 'http://localhost'
})
expect(code).toMatchSnapshot()
})
test('should allow for full base URLs, without protocol', () => {
const { code } = compileWithAssetUrls(`<img src="./logo.png" />`, {
base: '//localhost'
})
expect(code).toMatchSnapshot()
})
})