Skip to content

Commit

Permalink
Fixed temporal selector parsing (2)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenwf committed Jun 3, 2024
1 parent 1c8fd46 commit fe95043
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
36 changes: 32 additions & 4 deletions __tests__/parse-selector.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2002,15 +2002,15 @@ describe('parse selector', () => {
"selector": {
"temporal": {
"endTime": undefined,
"startTime": 0.5,
"startTime": 10.5,
},
"type": "TemporalSelector",
},
"selectors": [
{
"temporal": {
"endTime": undefined,
"startTime": 0.5,
"startTime": 10.5,
},
"type": "TemporalSelector",
},
Expand All @@ -2029,15 +2029,43 @@ describe('parse selector', () => {
"selector": {
"temporal": {
"endTime": 20.5,
"startTime": 0.5,
"startTime": 10.5,
},
"type": "TemporalSelector",
},
"selectors": [
{
"temporal": {
"endTime": 20.5,
"startTime": 0.5,
"startTime": 10.5,
},
"type": "TemporalSelector",
},
],
}
`);
});

test('temporal with start offset', () => {
const selector: Selector = {
type: 'FragmentSelector',
value: 't=302.05,3971.24',
};

expect(parseSelector(selector)).toMatchInlineSnapshot(`
{
"selector": {
"temporal": {
"endTime": 3971.24,
"startTime": 302.05,
},
"type": "TemporalSelector",
},
"selectors": [
{
"temporal": {
"endTime": 3971.24,
"startTime": 302.05,
},
"type": "TemporalSelector",
},
Expand Down
2 changes: 1 addition & 1 deletion src/annotation-targets/parse-selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export function parseSelector(
const selector: TemporalSelector = {
type: 'TemporalSelector',
temporal: {
startTime: matchTimeSelector[4] ? parseFloat(matchTimeSelector[4]) : 0,
startTime: matchTimeSelector[3] ? parseFloat(matchTimeSelector[3]) : 0,
endTime: matchTimeSelector[6] ? parseFloat(matchTimeSelector[6]) : undefined,
},
};
Expand Down

0 comments on commit fe95043

Please sign in to comment.