Skip to content
This repository has been archived by the owner on May 17, 2023. It is now read-only.

Commit

Permalink
Merge pull request #14 from duckduckgo/dharb/path-helper
Browse files Browse the repository at this point in the history
add new helper that returns domain with path
  • Loading branch information
bbraithwaite authored Jun 9, 2017
2 parents 505fb26 + 53fca49 commit cff97a1
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions template_helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cff97a1

Please sign in to comment.