Skip to content

Commit

Permalink
Don't include # if there isn't any media fragment
Browse files Browse the repository at this point in the history
  • Loading branch information
cjcolvar committed Mar 12, 2019
1 parent 18d0690 commit d4b9e14
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/iiif_manifest/v3/manifest_builder/canvas_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def canvas

def path
path = "#{parent.manifest_url}/canvas/#{record.id}"
path << "##{record.media_fragment}" if record.respond_to?(:media_fragment)
path << "##{record.media_fragment}" if record.respond_to?(:media_fragment) && record.media_fragment.present?
path
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@
it 'returns a canvas url' do
expect(builder.path).to eq 'http://test.host/books/book-77/manifest/canvas/test-22#xywh=160,120,320,240'
end

context 'and is blank' do
before do
allow(record).to receive(:media_fragment).and_return(nil)
end
it 'returns a canvas url' do
expect(builder.path).to eq 'http://test.host/books/book-77/manifest/canvas/test-22'
end
end
end
end
end

0 comments on commit d4b9e14

Please sign in to comment.