Strip protocol and trailing slashes from URLs

This commit is contained in:
Rafael Bardini 2020-10-31 14:20:25 +01:00
parent d5104af1a5
commit a3a35372ed
8 changed files with 15 additions and 11 deletions

View File

@ -22,6 +22,10 @@ Handlebars.registerHelper('formatDate', dateString =>
}),
)
Handlebars.registerHelper('formatURL', url =>
url.replace(/^(https?:|)\/\//, '').replace(/\/$/, ''),
)
Handlebars.registerHelper('join', (arr, separator) =>
arr.join(typeof separator === 'string' ? separator : ', '),
)

View File

@ -16,7 +16,7 @@
{{#url}}
<div>
<h6>Website</h6>
<a href="{{.}}">{{.}}</a>
<a href="{{.}}">{{formatURL .}}</a>
</div>
{{/url}}
</div>

View File

@ -17,7 +17,7 @@
<strong>{{.}}</strong>
{{/area}}
{{#url}}
<a href="{{.}}">{{.}}</a>
<a href="{{.}}">{{formatURL .}}</a>
{{/url}}
</div>
</header>

View File

@ -22,7 +22,7 @@
{{/entity}}
</span>
{{#url}}
<a href="{{.}}">{{.}}</a>
<a href="{{.}}">{{formatURL .}}</a>
{{/url}}
</div>
</header>

View File

@ -18,7 +18,7 @@
</span>
{{/publisher}}
{{#url}}
<a href="{{.}}">{{.}}</a>
<a href="{{.}}">{{formatURL .}}</a>
{{/url}}
</div>
</header>

View File

@ -17,7 +17,7 @@
<strong>{{.}}</strong>
{{/position}}
{{#url}}
<a href="{{.}}">{{.}}</a>
<a href="{{.}}">{{formatURL .}}</a>
{{/url}}
</div>
</header>

View File

@ -17,7 +17,7 @@
<strong>{{.}}</strong>
{{/position}}
{{#url}}
<a href="{{.}}">{{.}}</a>
<a href="{{.}}">{{formatURL .}}</a>
{{/url}}
</div>
</header>

View File

@ -246,7 +246,7 @@ blockquote > * + * {
</div>
<div>
<h6>Website</h6>
<a href="http://richardhendricks.example.com">http://richardhendricks.example.com</a>
<a href="http://richardhendricks.example.com">richardhendricks.example.com</a>
</div>
</div>
</section>
@ -284,7 +284,7 @@ blockquote > * + * {
</div>
<div class="spaced-list">
<strong>CEO/President</strong>
<a href="http://piedpiper.example.com">http://piedpiper.example.com</a>
<a href="http://piedpiper.example.com">piedpiper.example.com</a>
</div>
</header>
<p>Pied Piper is a multi-platform technology based on a proprietary universal compression algorithm that has consistently fielded high Weisman Scores that are not merely competitive, but approach the theoretical limit of lossless compression.</p>
@ -311,7 +311,7 @@ blockquote > * + * {
</div>
<div class="spaced-list">
<strong>Teacher</strong>
<a href="http://coderdojo.example.com/">http://coderdojo.example.com/</a>
<a href="http://coderdojo.example.com/">coderdojo.example.com</a>
</div>
</header>
<p>Global movement of free coding clubs for young people.</p>
@ -336,7 +336,7 @@ blockquote > * + * {
</div>
<div class="spaced-list">
<strong>Information Technology</strong>
<a href="https://www.ou.edu/">https://www.ou.edu/</a>
<a href="https://www.ou.edu/">www.ou.edu</a>
</div>
</header>
<p>Bachelor</p>
@ -410,7 +410,7 @@ blockquote > * + * {
<span>
Published by <strong>Hooli</strong>
</span>
<a href="http://en.wikipedia.org/wiki/Silicon_Valley_(TV_series)">http://en.wikipedia.org/wiki/Silicon_Valley_(TV_series)</a>
<a href="http://en.wikipedia.org/wiki/Silicon_Valley_(TV_series)">en.wikipedia.org/wiki/Silicon_Valley_(TV_series)</a>
</div>
</header>
<p>Innovative middle-out compression algorithm that changes the way we store data.</p>