Commit eafa6e25 authored by gergely-ujvari's avatar gergely-ujvari

Merge pull request #1617 from hypothesis/fix-annotation-titles

Check to see if an annotation has multiple titles
parents cbb12b52 4dbe612d
......@@ -187,11 +187,15 @@ AnnotationController = [
break
domain = extractURIComponent(uri, 'hostname')
documentTitle = if Array.isArray(model.document.title)
model.document.title[0]
else
model.document.title
@document =
uri: uri
domain: domain
title: model.document.title or domain
title: documentTitle or domain
if @document.title.length > 30
@document.title = @document.title[0..29] + '…'
......
......@@ -36,6 +36,12 @@ describe 'h.directives.annotation', ->
$scope.$digest()
assert.equal(controller.document.title, 'A special document')
it 'uses the first title when there are more than one', ->
annotation.document.title = ['first title', 'second title']
controller = createController()
$scope.$digest()
assert.equal(controller.document.title, 'first title')
it 'truncates long titles', ->
annotation.document.title = '''A very very very long title that really
shouldn't be found on a page on the internet.'''
......
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