Skip to content

Commit

Permalink
VTT detection not dependent on filename
Browse files Browse the repository at this point in the history
The logic for determining if a file is a VTT file is now based on the
media type, not the filename or its extension.
  • Loading branch information
edsu committed May 16, 2023
1 parent 033d2ba commit 7568bb1
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/models/embed/purl/resource_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def vtt
end

def vtt?
mimetype == 'text/vtt' && title.end_with?('.vtt')
mimetype == 'text/vtt'
end

def pdf?
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/purl_fixtures.rb
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ def video_purl_with_vtt
<contentMetadata type="media">
<resource sequence="1" id="abc123_1" type="video">
<file id="abc_123.mp4" mimetype="video/mp4" size="152000000"></file>
<file id="abc_123_cap.vtt" mimetype="text/vtt" size="176218"></file>
<file id="abc_123_cap.webvtt" mimetype="text/vtt" size="176218"></file>
</resource>
</contentMetadata>
<rightsMetadata>
Expand Down
2 changes: 1 addition & 1 deletion spec/models/embed/purl/resource_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

before { stub_purl_response_with_fixture(video_purl_with_vtt) }

it { is_expected.to eq 'abc_123_cap.vtt' }
it { is_expected.to eq 'abc_123_cap.webvtt' }
end

context 'when it does not have a vtt transcript' do
Expand Down

0 comments on commit 7568bb1

Please sign in to comment.