From 3b85cf045ea4e654e907fc5ea3aa0a4f8320571c Mon Sep 17 00:00:00 2001 From: Sukka Date: Tue, 1 Sep 2020 13:49:34 +0800 Subject: [PATCH] fix: handle invalid URL (#163) --- lib/renderer.js | 11 ++++++++++- test/index.js | 10 ++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/renderer.js b/lib/renderer.js index ef26b74..520380c 100644 --- a/lib/renderer.js +++ b/lib/renderer.js @@ -51,7 +51,16 @@ class Renderer extends MarkedRenderer { } } - let out = ` { ].join('\n')); }); + it('shouldn\'t encode when not a valid URL', () => { + const url = 'http://localhost:4000你好'; + + const body = `[foo](${url})`; + + const result = r({text: body}); + + result.should.eql(`

foo

\n`); + }); + describe('autolink option tests', () => { const hexo = new Hexo(__dirname, {silent: true}); const ctx = Object.assign(hexo, {