Commit d4330992 authored by Jake Hartnell's avatar Jake Hartnell

Don't via via

Fixes #2371
Adds test.
parent 797bf070
...@@ -18,7 +18,11 @@ module.exports = ['crossframe', (crossframe) -> ...@@ -18,7 +18,11 @@ module.exports = ['crossframe', (crossframe) ->
scope.$watchCollection (-> crossframe.frames), (frames) -> scope.$watchCollection (-> crossframe.frames), (frames) ->
if not frames.length if not frames.length
return return
# XXX: Consider sharing multiple frames in the future? # Check to see if we are on a via page. If so, we just return the URI.
re = /https:\/\/via\.hypothes\.is/
if re.test(frames[0].uri)
scope.viaPageLink = frames[0].uri
else
scope.viaPageLink = 'https://via.hypothes.is/' + frames[0].uri scope.viaPageLink = 'https://via.hypothes.is/' + frames[0].uri
restrict: 'A' restrict: 'A'
......
...@@ -30,3 +30,10 @@ describe 'share-dialog', -> ...@@ -30,3 +30,10 @@ describe 'share-dialog', ->
$scope.$digest() $scope.$digest()
assert.equal($scope.viaPageLink, assert.equal($scope.viaPageLink,
'https://via.hypothes.is/http://example.com') 'https://via.hypothes.is/http://example.com')
it 'does not generate new via link if already on via', ->
$element = $compile('<div share-dialog="">')($scope)
fakeCrossFrame.frames.push({uri: ['https://via.hypothes.is/http://example.com']})
$scope.$digest()
assert.equal($scope.viaPageLink,
'https://via.hypothes.is/http://example.com')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment