diff --git a/src/core/render/compiler/image.js b/src/core/render/compiler/image.js index 982e5e55ed..f6f8209111 100644 --- a/src/core/render/compiler/image.js +++ b/src/core/render/compiler/image.js @@ -34,7 +34,7 @@ export const imageCompiler = ({ renderer, contentBase, router }) => attrs.push(`id="${config.id}"`); } - if (!isAbsolutePath(href)) { + if (!isAbsolutePath(href, config.absolute)) { url = getPath(contentBase, getParentPath(router.getCurrentPath()), href); } diff --git a/src/core/router/util.js b/src/core/router/util.js index b4a85d89e1..6cf92df2b5 100644 --- a/src/core/router/util.js +++ b/src/core/router/util.js @@ -40,7 +40,11 @@ export function stringifyQuery(obj, ignores = []) { return qs.length ? `?${qs.join('&')}` : ''; } -export const isAbsolutePath = cached(path => { +export const isAbsolutePath = (path = '', absoluteConfig = false) => { + return !!absoluteConfig || absolutePath(path); +}; + +const absolutePath = cached(path => { return /(:|(\/{2}))/g.test(path); }); diff --git a/test/integration/render.test.js b/test/integration/render.test.js index f1335a0642..b8889704c9 100644 --- a/test/integration/render.test.js +++ b/test/integration/render.test.js @@ -128,6 +128,14 @@ describe('render', function () { ); }); + test('absolute', async function () { + const output = window.marked(""); + + expect(output).toMatchInlineSnapshot( + `"