diff options
author | newhinton <felix.nuesse@t-online.de> | 2019-05-12 14:33:12 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-12 14:33:12 +0300 |
commit | a765f32aa0df1e14510c4c012f8cf9b4aee9b741 (patch) | |
tree | 1093f599768c84ea35c1f6aa3d40046fad24ff02 /js/app | |
parent | 842d735216e6bf61d8a86e28109653fd75c451dc (diff) | |
parent | e4437bc244ffe8bae66db9d18b4e9a2ffbb88812 (diff) |
Merge pull request #527 from nextcloud/fix/526/url_not_opening
Updated link-detection in detailview and fixed link only redirecting …
Diffstat (limited to 'js/app')
-rw-r--r-- | js/app/directives/credentialfield.js | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/js/app/directives/credentialfield.js b/js/app/directives/credentialfield.js index 44a6c276..c0a9490e 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', + isURLFIELD: '=url', }, restrict: 'A', replace: 'true', @@ -49,8 +50,9 @@ '</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" 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 class="cell" ng-if="isURLFIELD && 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="isURLFIELD && isPartialLink"><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; @@ -67,10 +69,13 @@ } if (regex.test(scope.value)) { scope.isLink = true; - if(scope.value.substr(0,4) !== 'http'){ - scope.value = 'http://'+scope.value; + } else { + scope.isLink = false; + if(regex.test('https://'+scope.value)){ + scope.isPartialLink = true; } } + } }); if (!scope.toggle) { |