diff --git a/template_helpers.js b/template_helpers.js index ca6dcf1..1152db3 100644 --- a/template_helpers.js +++ b/template_helpers.js @@ -166,6 +166,17 @@ } }); + // Gets the domain with path of a given URL. + // It converts things like: http://blogs.wsj.com/law/2013/11/14/google-wins-dismissal-of-book-scanning-suit/?mod=smallbusiness/ + // Into: blogs.wsj.com/law/2013/11/14/google-wins-dismissal-of-book-scanning-suit/?mod=smallbusiness/ + Handlebars.registerHelper("domainWithPath", function(url) { + var re = new RegExp('^.*?\/\/([^\?\:\#]+)'); + if (re.test(url)) { + return RegExp.$1.replace('www.','').replace(/\/$/,''); + } + }); + + /** * * @function durationFormat