mirror of https://github.com/keeweb/keeweb.git
26 lines
663 B
JavaScript
26 lines
663 B
JavaScript
const FieldViewText = require('./field-view-text');
|
|
|
|
const FieldViewUrl = FieldViewText.extend({
|
|
displayUrlRegex: /^http:\/\//i,
|
|
|
|
renderValue: function(value) {
|
|
return value
|
|
? '<a href="' +
|
|
_.escape(this.fixUrl(value)) +
|
|
'" rel="noreferrer noopener" target="_blank">' +
|
|
_.escape(this.displayUrl(value)) +
|
|
'</a>'
|
|
: '';
|
|
},
|
|
|
|
fixUrl: function(url) {
|
|
return url.indexOf(':') < 0 ? 'http://' + url : url;
|
|
},
|
|
|
|
displayUrl: function(url) {
|
|
return url.replace(this.displayUrlRegex, '');
|
|
}
|
|
});
|
|
|
|
module.exports = FieldViewUrl;
|