fix(compiler-sfc): support transforming asset urls with full base url. (#2477)
This commit is contained in:
@@ -1,5 +1,37 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`compiler sfc: transform asset url should allow for full base URLs, with paths 1`] = `
|
||||
"import { createVNode as _createVNode, openBlock as _openBlock, createBlock as _createBlock } from \\"vue\\"
|
||||
|
||||
export function render(_ctx, _cache) {
|
||||
return (_openBlock(), _createBlock(\\"img\\", { src: \\"http://localhost:3000/src/logo.png\\" }))
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`compiler sfc: transform asset url should allow for full base URLs, without paths 1`] = `
|
||||
"import { createVNode as _createVNode, openBlock as _openBlock, createBlock as _createBlock } from \\"vue\\"
|
||||
|
||||
export function render(_ctx, _cache) {
|
||||
return (_openBlock(), _createBlock(\\"img\\", { src: \\"http://localhost:3000/logo.png\\" }))
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`compiler sfc: transform asset url should allow for full base URLs, without port 1`] = `
|
||||
"import { createVNode as _createVNode, openBlock as _openBlock, createBlock as _createBlock } from \\"vue\\"
|
||||
|
||||
export function render(_ctx, _cache) {
|
||||
return (_openBlock(), _createBlock(\\"img\\", { src: \\"http://localhost/logo.png\\" }))
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`compiler sfc: transform asset url should allow for full base URLs, without protocol 1`] = `
|
||||
"import { createVNode as _createVNode, openBlock as _openBlock, createBlock as _createBlock } from \\"vue\\"
|
||||
|
||||
export function render(_ctx, _cache) {
|
||||
return (_openBlock(), _createBlock(\\"img\\", { src: \\"//localhost/logo.png\\" }))
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`compiler sfc: transform asset url support uri fragment 1`] = `
|
||||
"import { createVNode as _createVNode, openBlock as _openBlock, createBlock as _createBlock } from \\"vue\\"
|
||||
import _imports_0 from '@svg/file.svg'
|
||||
|
||||
@@ -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()
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user