From 55e75a9e49fd9301bc879ec25b71851f94f7d174 Mon Sep 17 00:00:00 2001 From: Aaron Gershman Date: Thu, 5 May 2022 17:55:58 -0500 Subject: [PATCH] Strip protocol off URL under basics --- index.js | 5 +++++ partials/basics.hbs | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 6fea29e..57dc093 100644 --- a/index.js +++ b/index.js @@ -15,6 +15,11 @@ fs.readdirSync(partialsDir) Handlebars.registerPartial(path.basename(filename, extname), template), ) +Handlebars.registerHelper('STRIP_PROTOCOL', urlStr => { + const result = urlStr.replace(/(^\w+:|^)\/\//, ''); + return result; +}) + Handlebars.registerHelper('MONTH_YEAR', dateString => // https://dockyard.com/blog/2020/02/14/you-probably-don-t-need-moment-js-anymore new Date(dateString).toLocaleDateString('en', { diff --git a/partials/basics.hbs b/partials/basics.hbs index 8c25752..1de3b8f 100644 --- a/partials/basics.hbs +++ b/partials/basics.hbs @@ -29,7 +29,7 @@ {{#if url}} | - {{url}} + {{STRIP_PROTOCOL url}} {{/if}} {{#location}}