mirror of https://github.com/keeweb/keeweb.git
fix #68: url display without http
This commit is contained in:
parent
2693072a5e
commit
37183ed978
|
@ -9,6 +9,7 @@ var Backbone = require('backbone'),
|
|||
|
||||
var EntryModel = Backbone.Model.extend({
|
||||
defaults: {},
|
||||
urlRegex: /^https?:\/\//i,
|
||||
|
||||
buildInFields: ['Title', 'Password', 'Notes', 'URL', 'UserName'],
|
||||
|
||||
|
@ -33,6 +34,7 @@ var EntryModel = Backbone.Model.extend({
|
|||
this.password = entry.fields.Password || kdbxweb.ProtectedValue.fromString('');
|
||||
this.notes = entry.fields.Notes || '';
|
||||
this.url = entry.fields.URL || '';
|
||||
this.displayUrl = this._getDisplayUrl(entry.fields.URL);
|
||||
this.user = entry.fields.UserName || '';
|
||||
this.iconId = entry.icon;
|
||||
this.icon = this._iconFromId(entry.icon);
|
||||
|
@ -97,6 +99,13 @@ var EntryModel = Backbone.Model.extend({
|
|||
return IconMap[id];
|
||||
},
|
||||
|
||||
_getDisplayUrl: function(url) {
|
||||
if (!url) {
|
||||
return '';
|
||||
}
|
||||
return url.replace(this.urlRegex, '');
|
||||
},
|
||||
|
||||
_colorToModel: function(color) {
|
||||
return color ? Color.getNearest(color) : null;
|
||||
},
|
||||
|
|
|
@ -25,7 +25,7 @@ EntryPresenter.prototype = {
|
|||
get color() { return this.entry ? (this.entry.color || (this.entry.customIcon ? this.noColor : undefined)) : undefined; },
|
||||
get title() { return this.entry ? this.entry.title : this.group.get('title'); },
|
||||
get notes() { return this.entry ? this.entry.notes : undefined; },
|
||||
get url() { return this.entry ? this.entry.url : undefined; },
|
||||
get url() { return this.entry ? this.entry.displayUrl : undefined; },
|
||||
get user() { return this.entry ? this.entry.user : undefined; },
|
||||
get active() { return this.entry ? this.entry.id === this.activeEntryId : this.group.active; },
|
||||
get created() { return this.entry ? Format.dtStr(this.entry.created) : undefined; },
|
||||
|
|
|
@ -3,12 +3,18 @@
|
|||
var FieldViewText = require('./field-view-text');
|
||||
|
||||
var FieldViewUrl = FieldViewText.extend({
|
||||
displayUrlRegex: /^http:\/\//i,
|
||||
|
||||
renderValue: function(value) {
|
||||
return value ? '<a href="' + _.escape(this.fixUrl(value)) + '" target="_blank">' + _.escape(value) + '</a>' : '';
|
||||
return value ? '<a href="' + _.escape(this.fixUrl(value)) + '" 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, '');
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ Improvements
|
|||
`+` help/tips
|
||||
`+` #50: notification on password copy
|
||||
`-` #74: select all in search field
|
||||
`*` #68: url display without http
|
||||
|
||||
##### v0.5.1 (2015-12-15)
|
||||
Layout bugfixes
|
||||
|
|
Loading…
Reference in New Issue