Commit add518ab by Johannes Edmeier

Remove dangling singlequote from href

Unfortunately js-yaml currently renders all strings in singlequotes, these are included by linkifyjs in the href. So this commits adds a formatHref option to remove these dangling singlequote.
parent 6d092235
...@@ -22,6 +22,13 @@ module.exports = function () { ...@@ -22,6 +22,13 @@ module.exports = function () {
var max = maxLength || Number.MAX_VALUE; var max = maxLength || Number.MAX_VALUE;
return linkify(input, { return linkify(input, {
target: '_blank', target: '_blank',
formatHref: function (href, type) {
if (type === 'url') {
//the yaml filter quotes all strings with singlequotes which then shows up in the href so we remove them here
return href.replace(/'$/, '');
}
return href;
},
format: function(url, type) { format: function(url, type) {
if (type === 'url' && url.length > max) { if (type === 'url' && url.length > max) {
url = url.replace(/https?:\/\//, ''); url = url.replace(/https?:\/\//, '');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment