_createElementVNode(\\"img\\", { src: _imports_1 }),
_createElementVNode(\\"img\\", { src: _imports_1 }),
_createElementVNode(\\"img\\", { src: \\"http://example.com/fixtures/logo.png\\" }),
+ _createElementVNode(\\"img\\", { src: \\"//example.com/fixtures/logo.png\\" }),
_createElementVNode(\\"img\\", { src: \\"/fixtures/logo.png\\" }),
_createElementVNode(\\"img\\", { src: \\"data:image/png;base64,i\\" })
], 64 /* STABLE_FRAGMENT */))
return (_openBlock(), _createElementBlock(_Fragment, null, [
_createElementVNode(\\"img\\", { src: _imports_0 }),
_createElementVNode(\\"img\\", { src: _imports_1 }),
- _createElementVNode(\\"img\\", { src: \\"https://foo.bar/baz.png\\" })
+ _createElementVNode(\\"img\\", { src: \\"https://foo.bar/baz.png\\" }),
+ _createElementVNode(\\"img\\", { src: \\"//foo.bar/baz.png\\" })
], 64 /* STABLE_FRAGMENT */))
}"
`;
<img src="~fixtures/logo.png"/>
<img src="~/fixtures/logo.png"/>
<img src="http://example.com/fixtures/logo.png"/>
+ <img src="//example.com/fixtures/logo.png"/>
<img src="/fixtures/logo.png"/>
<img src="data:image/png;base64,i"/>
`)
const { code } = compileWithAssetUrls(
`<img src="./bar.png"/>` +
`<img src="/bar.png"/>` +
- `<img src="https://foo.bar/baz.png"/>`,
+ `<img src="https://foo.bar/baz.png"/>` +
+ `<img src="//foo.bar/baz.png"/>`,
{
includeAbsolute: true
}
const result = isExternalUrl(url)
expect(result).toBe(true)
})
+
+ test('should return true when String starts with //', () => {
+ const url = '//vuejs.org/'
+ const result = isExternalUrl(url)
+ expect(result).toBe(true)
+ })
})
describe('compiler sfc:templateUtils isDataUrl', () => {
return firstChar === '.' || firstChar === '~' || firstChar === '@'
}
-const externalRE = /^https?:\/\//
+const externalRE = /^(https?:)?\/\//
export function isExternalUrl(url: string): boolean {
return externalRE.test(url)
}