Skip to content
Snippets Groups Projects
Commit 28b5784d authored by Jack Reed's avatar Jack Reed
Browse files

update fragmentSelector to return Integer values instead of String

parent ecad5306
No related branches found
No related tags found
No related merge requests found
...@@ -53,11 +53,11 @@ describe('AnnotationResource', () => { ...@@ -53,11 +53,11 @@ describe('AnnotationResource', () => {
describe('fragmentSelector', () => { describe('fragmentSelector', () => {
it('simple string', () => { it('simple string', () => {
expect(new AnnotationResource({ on: 'www.example.com/#xywh=10,10,100,200' }) expect(new AnnotationResource({ on: 'www.example.com/#xywh=10,10,100,200' })
.fragmentSelector).toEqual(['10', '10', '100', '200']); .fragmentSelector).toEqual([10, 10, 100, 200]);
}); });
it('more complex selector', () => { it('more complex selector', () => {
expect(new AnnotationResource({ on: { selector: { value: 'www.example.com/#xywh=10,10,100,200' } } }) expect(new AnnotationResource({ on: { selector: { value: 'www.example.com/#xywh=10,10,100,200' } } })
.fragmentSelector).toEqual(['10', '10', '100', '200']); .fragmentSelector).toEqual([10, 10, 100, 200]);
}); });
}); });
}); });
...@@ -37,9 +37,9 @@ export default class AnnotationResource { ...@@ -37,9 +37,9 @@ export default class AnnotationResource {
const { on } = this.resource; const { on } = this.resource;
switch (typeof on) { switch (typeof on) {
case 'string': case 'string':
return on.match(/xywh=(.*)$/)[1].split(','); return on.match(/xywh=(.*)$/)[1].split(',').map(str => parseInt(str, 10));
case 'object': case 'object':
return on.selector.value.match(/xywh=(.*)$/)[1].split(','); return on.selector.value.match(/xywh=(.*)$/)[1].split(',').map(str => parseInt(str, 10));
default: default:
return null; return null;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment