Commit 4dbe612d authored by Aron Carroll's avatar Aron Carroll

Check to see if an annotation has multiple titles

Fixes the issue where a document title appears in square brackets.
parent cbb12b52
...@@ -187,11 +187,15 @@ AnnotationController = [ ...@@ -187,11 +187,15 @@ AnnotationController = [
break break
domain = extractURIComponent(uri, 'hostname') domain = extractURIComponent(uri, 'hostname')
documentTitle = if Array.isArray(model.document.title)
model.document.title[0]
else
model.document.title
@document = @document =
uri: uri uri: uri
domain: domain domain: domain
title: model.document.title or domain title: documentTitle or domain
if @document.title.length > 30 if @document.title.length > 30
@document.title = @document.title[0..29] + '…' @document.title = @document.title[0..29] + '…'
......
...@@ -36,6 +36,12 @@ describe 'h.directives.annotation', -> ...@@ -36,6 +36,12 @@ describe 'h.directives.annotation', ->
$scope.$digest() $scope.$digest()
assert.equal(controller.document.title, 'A special document') 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', -> it 'truncates long titles', ->
annotation.document.title = '''A very very very long title that really annotation.document.title = '''A very very very long title that really
shouldn't be found on a page on the internet.''' 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