fix(compiler-sfc): only transform relative asset URLs (#628)
This commit is contained in:
@@ -33,7 +33,9 @@ export function render() {
|
||||
return (openBlock(), createBlock(Fragment, null, [
|
||||
createVNode(\\"img\\", { src: _imports_0 }),
|
||||
createVNode(\\"img\\", { src: _imports_1 }),
|
||||
createVNode(\\"img\\", { src: _imports_1 })
|
||||
createVNode(\\"img\\", { src: _imports_1 }),
|
||||
createVNode(\\"img\\", { src: \\"http://example.com/fixtures/logo.png\\" }),
|
||||
createVNode(\\"img\\", { src: \\"/fixtures/logo.png\\" })
|
||||
], 64 /* STABLE_FRAGMENT */))
|
||||
}"
|
||||
`;
|
||||
|
||||
@@ -12,6 +12,7 @@ const _hoisted_4 = _imports_0 + ', ' + _imports_0 + '2x'
|
||||
const _hoisted_5 = _imports_0 + '2x, ' + _imports_0
|
||||
const _hoisted_6 = _imports_0 + '2x, ' + _imports_0 + '3x'
|
||||
const _hoisted_7 = _imports_0 + ', ' + _imports_0 + '2x, ' + _imports_0 + '3x'
|
||||
const _hoisted_8 = \\"/logo.png\\" + ', ' + _imports_0 + '2x'
|
||||
|
||||
export function render() {
|
||||
const _ctx = this
|
||||
@@ -43,6 +44,18 @@ export function render() {
|
||||
createVNode(\\"img\\", {
|
||||
src: \\"./logo.png\\",
|
||||
srcset: _hoisted_7
|
||||
}),
|
||||
createVNode(\\"img\\", {
|
||||
src: \\"/logo.png\\",
|
||||
srcset: \\"/logo.png, /logo.png 2x\\"
|
||||
}),
|
||||
createVNode(\\"img\\", {
|
||||
src: \\"https://example.com/logo.png\\",
|
||||
srcset: \\"https://example.com/logo.png, https://example.com/logo.png 2x\\"
|
||||
}),
|
||||
createVNode(\\"img\\", {
|
||||
src: \\"/logo.png\\",
|
||||
srcset: _hoisted_8
|
||||
})
|
||||
], 64 /* STABLE_FRAGMENT */))
|
||||
}"
|
||||
|
||||
@@ -50,7 +50,7 @@ test('warn missing preprocessor', () => {
|
||||
})
|
||||
|
||||
test('transform asset url options', () => {
|
||||
const input = { source: `<foo bar="baz"/>`, filename: 'example.vue' }
|
||||
const input = { source: `<foo bar="~baz"/>`, filename: 'example.vue' }
|
||||
// Object option
|
||||
const { code: code1 } = compileTemplate({
|
||||
...input,
|
||||
|
||||
@@ -20,6 +20,8 @@ describe('compiler sfc: transform asset url', () => {
|
||||
<img src="./logo.png"/>
|
||||
<img src="~fixtures/logo.png"/>
|
||||
<img src="~/fixtures/logo.png"/>
|
||||
<img src="http://example.com/fixtures/logo.png"/>
|
||||
<img src="/fixtures/logo.png"/>
|
||||
`)
|
||||
|
||||
expect(result.code).toMatchSnapshot()
|
||||
|
||||
@@ -24,6 +24,9 @@ describe('compiler sfc: transform srcset', () => {
|
||||
<img src="./logo.png" srcset="./logo.png 2x, ./logo.png"/>
|
||||
<img src="./logo.png" srcset="./logo.png 2x, ./logo.png 3x"/>
|
||||
<img src="./logo.png" srcset="./logo.png, ./logo.png 2x, ./logo.png 3x"/>
|
||||
<img src="/logo.png" srcset="/logo.png, /logo.png 2x"/>
|
||||
<img src="https://example.com/logo.png" srcset="https://example.com/logo.png, https://example.com/logo.png 2x"/>
|
||||
<img src="/logo.png" srcset="/logo.png, ./logo.png 2x"/>
|
||||
`)
|
||||
|
||||
expect(result.code).toMatchSnapshot()
|
||||
|
||||
Reference in New Issue
Block a user