From 6ad0ba6a9ed2104908650429cfb5c0b4094cca70 Mon Sep 17 00:00:00 2001 From: Dan Allen Date: Sat, 24 Aug 2019 17:20:44 -0600 Subject: [PATCH] prepend site path when resolving relative URL if from is undefined or empty --- src/helpers/relativize.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/helpers/relativize.js b/src/helpers/relativize.js index 950703a..76adfa4 100644 --- a/src/helpers/relativize.js +++ b/src/helpers/relativize.js @@ -12,9 +12,10 @@ function relativize (to, ctx) { from = ctx.data.root.page.url } if (!to) return '#' - if (!from || to.charAt() === '#') return to - let hash = '' const hashIdx = to.indexOf('#') + if (!hashIdx) return to + if (!from) return (ctx.data.root.site.path || '') + to + let hash = '' if (~hashIdx) { hash = to.substr(hashIdx) to = to.substr(0, hashIdx) -- 2.11.0