From c07de3ea5caecd3ed59476facd76ccc2ecd0ac1b Mon Sep 17 00:00:00 2001 From: Vitaliy Ribachenko Date: Mon, 1 Jul 2019 21:05:44 +0300 Subject: [PATCH] Remove baseUrl if its just a slash --- lib/marked.js | 3 +++ test/specs/new/base_url_root.html | 3 +++ test/specs/new/base_url_root.md | 4 ++++ 3 files changed, 10 insertions(+) create mode 100644 test/specs/new/base_url_root.html create mode 100644 test/specs/new/base_url_root.md diff --git a/lib/marked.js b/lib/marked.js index d07c39618f..5e6455d6b9 100644 --- a/lib/marked.js +++ b/lib/marked.js @@ -1119,6 +1119,9 @@ function Parser(options) { this.tokens = []; this.token = null; this.options = options || marked.defaults; + if (this.options.baseUrl && this.options.baseUrl.trim() === '/') { + delete this.options.baseUrl; + } this.options.renderer = this.options.renderer || new Renderer(); this.renderer = this.options.renderer; this.renderer.options = this.options; diff --git a/test/specs/new/base_url_root.html b/test/specs/new/base_url_root.html new file mode 100644 index 0000000000..e0f34afbc0 --- /dev/null +++ b/test/specs/new/base_url_root.html @@ -0,0 +1,3 @@ +

+ Image +

\ No newline at end of file diff --git a/test/specs/new/base_url_root.md b/test/specs/new/base_url_root.md new file mode 100644 index 0000000000..d68e89c1eb --- /dev/null +++ b/test/specs/new/base_url_root.md @@ -0,0 +1,4 @@ +--- +baseUrl: "/" +--- +![Image](/images/pic01.jpg) \ No newline at end of file