diff options
author | fnuesse <felix.nuesse@t-online.de> | 2018-12-22 12:44:06 +0300 |
---|---|---|
committer | fnuesse <felix.nuesse@t-online.de> | 2018-12-22 12:44:06 +0300 |
commit | 2550bc6552378775e34ee2f9ec39c4991c5d38d7 (patch) | |
tree | 9c0f58f23f3a97e87f3d5d29b881e080b9139334 /js/app | |
parent | 0751fbf2c67a72986a134e35321b3c0b8fbf9d6c (diff) |
Updated link-detection in detailview and fixed link only redirecting to cloud.com/server/apps/passman/{{link}} in detailview
Signed-off-by: fnuesse <felix.nuesse@t-online.de>
Diffstat (limited to 'js/app')
-rw-r--r-- | js/app/directives/credentialfield.js | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/js/app/directives/credentialfield.js b/js/app/directives/credentialfield.js index 44a6c276..6e0efd17 100644 --- a/js/app/directives/credentialfield.js +++ b/js/app/directives/credentialfield.js @@ -36,7 +36,8 @@ value: '=value', secret: '=secret', inputField: '=useInput', - inputFieldplaceholder: '=inputPlaceholder' + inputFieldplaceholder: '=inputPlaceholder', + isURL: '=isurl' }, restrict: 'A', replace: 'true', @@ -49,11 +50,11 @@ '</div>' + '<div class="tools">' + '<div class="cell" ng-if="toggle" tooltip="tggltxt" ng-click="toggleVisibility()"><i class="fa" ng-class="{\'fa-eye\': !valueVisible, \'fa-eye-slash\': valueVisible }"></i></div>' + - '<div class="cell" ng-if="isLink"><a ng-href="{{value}}" target="_blank" rel="nofollow noopener noreferrer"><i tooltip="\'Open in new window\'" class="link fa fa-external-link"></i></a></div>' + + '<div class="cell" ng-if="isLink"><a ng-href="//{{value}}" target="_blank" rel="nofollow noopener noreferrer"><i tooltip="\'Open in new window\'" class="link fa fa-external-link"></i></a></div>' + '<div class="cell" ngclipboard-success="onSuccess(e);" ngclipboard-error="onError(e);" ngclipboard data-clipboard-text="{{value}}"><i tooltip="copy_msg" class="fa fa-files-o"></i></div>' + '</div></span>', link: function (scope) { - var expression = /(https?:\/\/(?:www\.|(?!www))[^\s\.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})/gi; + var expression = /(https?:\/\/(?:www\.|(?!www))[^\s\.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})/gi; var regex = new RegExp(expression); $translate(['toggle.visibility','copy.field', 'copy', 'copied']).then(function (translations) { scope.tggltxt = translations['toggle.visibility']; @@ -67,9 +68,11 @@ } if (regex.test(scope.value)) { scope.isLink = true; - if(scope.value.substr(0,4) !== 'http'){ - scope.value = 'http://'+scope.value; - } + } else if (regex.test('http://'+scope.value) && scope.isURL){ + //This part is added to check if the user did not add http or https to the url and match it nonetheless + scope.isLink = true; + } else { + scope.isLink = false; } } }); |