@@ -161,6 +161,14 @@ describe('v35', () => {
161161 assert . throws ( ( ) => v3 ( 'hello.example.com' , null , new Uint8Array ( 16 ) ) ) ;
162162 } ) ;
163163
164+ test ( 'v3 throws RangeError for out-of-range indexes' , ( ) => {
165+ const buf15 = new Uint8Array ( 15 ) ;
166+ const buf30 = new Uint8Array ( 30 ) ;
167+ assert . throws ( ( ) => v3 ( 'hello.example.com' , v3 . DNS , buf15 ) , RangeError ) ;
168+ assert . throws ( ( ) => v3 ( 'hello.example.com' , v3 . DNS , buf30 , - 1 ) , RangeError ) ;
169+ assert . throws ( ( ) => v3 ( 'hello.example.com' , v3 . DNS , buf30 , 15 ) , RangeError ) ;
170+ } ) ;
171+
164172 test ( 'v5' , ( ) => {
165173 // Expect to get the same results as http://tools.adjet.org/uuid-v5
166174 assert . strictEqual (
@@ -269,6 +277,14 @@ describe('v35', () => {
269277 assert . throws ( ( ) => v5 ( 'hello.example.com' , null , new Uint8Array ( 16 ) ) ) ;
270278 } ) ;
271279
280+ test ( 'v5 throws RangeError for out-of-range indexes' , ( ) => {
281+ const buf15 = new Uint8Array ( 15 ) ;
282+ const buf30 = new Uint8Array ( 30 ) ;
283+ assert . throws ( ( ) => v5 ( 'hello.example.com' , v5 . DNS , buf15 ) , RangeError ) ;
284+ assert . throws ( ( ) => v5 ( 'hello.example.com' , v5 . DNS , buf30 , - 1 ) , RangeError ) ;
285+ assert . throws ( ( ) => v5 ( 'hello.example.com' , v5 . DNS , buf30 , 15 ) , RangeError ) ;
286+ } ) ;
287+
272288 test ( 'v3/v5 constants' , ( ) => {
273289 assert . strictEqual ( v3 . DNS , '6ba7b810-9dad-11d1-80b4-00c04fd430c8' ) ;
274290 assert . strictEqual ( v3 . URL , '6ba7b811-9dad-11d1-80b4-00c04fd430c8' ) ;
0 commit comments