Commit 29d46088 authored by wu-lee's avatar wu-lee

lib/helpers.js - fix url helper's absolute -> relative conversion

parent 08eb31db
......@@ -192,13 +192,16 @@ module.exports = {
url: function() {
const [options, path] = getopts(arguments);
const baseurl = options.data.root.config.urls.base;
var outputUrl = new URL(path || this.path, baseurl).href;
var outputUrl = new URL(path || this.path, baseurl);
// FIXME: is absolute /blah or https://foo/blah?
if (!options.hash.absolute)
outputUrl = outputUrl.substring(baseurl.length);
if (!options.hash.absolute)
outputUrl = outputUrl.href;
else
outputUrl = outputUrl.href.substring(outputUrl.origin.length);
outputUrl = encodeURI(outputUrl);
return new Handlebars.SafeString(outputUrl);
},
date: function() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment