Commit 0cd1220b authored by Randall Leeds's avatar Randall Leeds

Merge pull request #2378 from hypothesis/do-not-via-via

Don't via via
parents 6085e140 d4330992
......@@ -18,8 +18,12 @@ module.exports = ['crossframe', (crossframe) ->
scope.$watchCollection (-> crossframe.frames), (frames) ->
if not frames.length
return
# XXX: Consider sharing multiple frames in the future?
scope.viaPageLink = 'https://via.hypothes.is/' + frames[0].uri
# 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
restrict: 'A'
templateUrl: 'share_dialog.html'
......
......@@ -30,3 +30,10 @@ describe 'share-dialog', ->
$scope.$digest()
assert.equal($scope.viaPageLink,
'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