File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed
Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -41,12 +41,15 @@ const isStringVr = (vr) => stringVrs[vr];
4141 * Tests to see if a given tag in the format xggggeeee is a private tag or not
4242 * @param tag
4343 * @returns {boolean }
44+ * @throws error if fourth character cannot be parsed
4445 */
4546const isPrivateTag = ( tag ) => {
46- const lastGroupDigit = parseInt ( tag [ 4 ] , 10 ) ;
47+ const lastGroupDigit = parseInt ( tag [ 4 ] , 16 ) ;
48+ if ( isNaN ( lastGroupDigit ) ) {
49+ throw 'dicomParser.isPrivateTag: cannot parse last character of group' ;
50+ }
4751 const groupIsOdd = ( lastGroupDigit % 2 ) === 1 ;
4852
49-
5053 return groupIsOdd ;
5154} ;
5255
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ describe('util', () => {
66 describe ( '#isPrivateTag' , ( ) => {
77
88 it ( 'should return `true` for a private tag' , ( ) => {
9- const isPrivateTag = util . isPrivateTag ( 'x00190010 ' ) ;
9+ const isPrivateTag = util . isPrivateTag ( 'x001d0010 ' ) ;
1010 expect ( isPrivateTag ) . to . equal ( true ) ;
1111 } )
1212
@@ -15,6 +15,15 @@ describe('util', () => {
1515 expect ( isPrivateTag ) . to . equal ( false ) ;
1616 } )
1717
18+ it ( 'should throw an exception' , ( ) => {
19+ // Arrange
20+ const tag = 'x100z0010' ;
21+ const invoker = ( ) => util . isPrivateTag ( tag ) ;
22+
23+ // Act / Assert
24+ expect ( invoker ) . to . throw ( ) ;
25+ } ) ;
26+
1827 } ) ;
1928
2029 describe ( '#parsePN' , ( ) => {
You can’t perform that action at this time.
0 commit comments