diff options
author | fnuesse <felix.nuesse@t-online.de> | 2018-12-30 15:16:49 +0300 |
---|---|---|
committer | fnuesse <felix.nuesse@t-online.de> | 2018-12-30 15:16:49 +0300 |
commit | b5d8ba8e46a6d3b71b671120d28309651c5b34bc (patch) | |
tree | 31ec4190d115e6d2d932b886971736723f1dc0dc /js | |
parent | ee335aab8780b94b4a0d965129e7e87efca435ab (diff) |
Fixed wrong url-building in sidebar and updated codestyle
Signed-off-by: fnuesse <felix.nuesse@t-online.de>
Diffstat (limited to 'js')
-rw-r--r-- | js/app/directives/credentialfield.js | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/js/app/directives/credentialfield.js b/js/app/directives/credentialfield.js index feb54fd0..1812c64b 100644 --- a/js/app/directives/credentialfield.js +++ b/js/app/directives/credentialfield.js @@ -50,11 +50,12 @@ '</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="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="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; + 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']; @@ -68,16 +69,13 @@ } if (regex.test(scope.value)) { scope.isLink = true; - } 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; - } - if(scope.value.substr(0,4) !== 'http'){ - var val = scope.value; - scope.value =val.substr(val.indexOf("://")+3,val.length); + scope.isLink = false; + if(regex.test('https://'+scope.value)){ + scope.isPartialLink = true; + } } + } }); if (!scope.toggle) { |