Commit ab9beb74 authored by Robert Knight's avatar Robert Knight

Encode the frame URL when constructing the hyp.is link

If the URL is not encoded, a frame URL such as
"http://example.com/foo&bar=baz" will generate the page share link
"https://hyp.is/go?url=http://example.com/foo&bar=baz" where the
"&bar..." part becomes a separate parameter instead of part of the "url" param.
parent d3628722
......@@ -10,7 +10,7 @@ function ShareDialogController($scope, $element, analytics, store) {
return;
}
self.sharePageLink = 'https://hyp.is/go?url='+frames[0].uri;
self.sharePageLink = 'https://hyp.is/go?url=' + encodeURIComponent(frames[0].uri);
}
var shareLinkInput = $element[0].querySelector('.js-share-link');
......
......@@ -25,10 +25,11 @@ describe('shareDialog', function () {
it('generates new share link', function () {
var element = util.createDirective(document, 'shareDialog', {});
fakeStore.frames.returns([{ uri: 'http://example.com' }]);
var uri = 'http://example.com';
fakeStore.frames.returns([{ uri }]);
element.scope.$digest();
assert.equal(element.ctrl.sharePageLink,
'https://hyp.is/go?url=http://example.com');
'https://hyp.is/go?url=' + encodeURIComponent(uri));
});
it('tracks the target being shared', function(){
......
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