@@ -36,7 +36,7 @@ test("sourceId with forward slash is rejected", async () => {
3636
3737 await assert . rejects (
3838 ( ) => loadConfig ( configPath ) ,
39- / s o u r c e s \[ 0 \] \ .i d | a l p h a n u m e r i c / i,
39+ / s o u r c e s \. 0 \ .i d | p a t h s e p a r a t o r s | r e s e r v e d c h a r a c t e r s / i,
4040 ) ;
4141} ) ;
4242
@@ -47,7 +47,7 @@ test("sourceId with backslash is rejected", async () => {
4747
4848 await assert . rejects (
4949 ( ) => loadConfig ( configPath ) ,
50- / s o u r c e s \[ 0 \] \ .i d | a l p h a n u m e r i c / i,
50+ / s o u r c e s \. 0 \ .i d | p a t h s e p a r a t o r s | r e s e r v e d c h a r a c t e r s / i,
5151 ) ;
5252} ) ;
5353
@@ -72,20 +72,43 @@ test("source ID allows hyphen and underscore", async () => {
7272 }
7373} ) ;
7474
75- test ( "source ID rejects dots and at-signs" , async ( ) => {
75+ test ( "source ID allows dots and at-signs" , async ( ) => {
7676 const ids = [ "test.repo" , "test@v1.0" , "a.b" , "a@b" ] ;
7777
78+ for ( const id of ids ) {
79+ const configPath = await writeConfig ( {
80+ sources : [ { id, repo : "https://github.com/example/repo.git" } ] ,
81+ } ) ;
82+ const { sources } = await loadConfig ( configPath ) ;
83+ assert . equal ( sources [ 0 ] . id , id ) ;
84+ }
85+ } ) ;
86+
87+ test ( "source ID rejects trailing dots or spaces" , async ( ) => {
88+ const ids = [ "repo." , "repo " , "repo.." , "repo. " ] ;
89+
7890 for ( const id of ids ) {
7991 const configPath = await writeConfig ( {
8092 sources : [ { id, repo : "https://github.com/example/repo.git" } ] ,
8193 } ) ;
8294 await assert . rejects (
8395 ( ) => loadConfig ( configPath ) ,
84- / s o u r c e s \[ 0 \] \ .i d | a l p h a n u m e r i c / i,
96+ / s o u r c e s \. 0 \ .i d | d o t s o r s p a c e s / i,
8597 ) ;
8698 }
8799} ) ;
88100
101+ test ( "source ID rejects reserved names" , async ( ) => {
102+ const ids = [ "CON" , "AUX" , "NUL" , "PRN" ] ;
103+
104+ for ( const id of ids ) {
105+ const configPath = await writeConfig ( {
106+ sources : [ { id, repo : "https://github.com/example/repo.git" } ] ,
107+ } ) ;
108+ await assert . rejects ( ( ) => loadConfig ( configPath ) , / r e s e r v e d n a m e / i) ;
109+ }
110+ } ) ;
111+
89112test ( "targetDir with absolute path is rejected" , async ( ) => {
90113 const configPath = await writeConfig ( {
91114 sources : [
0 commit comments