@@ -80,4 +80,29 @@ public function testTestValidSSHKey(bool $expected, string $key)
8080 {
8181 $ this ->assertEquals ($ expected , testValidSSHKey ($ key ));
8282 }
83+
84+ public static function URLComponentProvider ()
85+ {
86+ if (CONFIG ["site " ]["prefix " ] != "http://127.0.0.1:8000 " ) {
87+ throw new RuntimeException ("site prefix has changed! " );
88+ }
89+ return [
90+ [["" , "" ], "http://127.0.0.1:8000 " ],
91+ [["" , "/ " ], "http://127.0.0.1:8000/ " ],
92+ [["/ " , "a " ], "http://127.0.0.1:8000/a " ],
93+ [["/ " , "/a " ], "http://127.0.0.1:8000/a " ],
94+ [["abc " , "def " ], "http://127.0.0.1:8000/abc/def " ],
95+ [["abc " , "/def " ], "http://127.0.0.1:8000/abc/def " ],
96+ [["/abc " , "def " ], "http://127.0.0.1:8000/abc/def " ],
97+ [["/abc " , "def/// " ], "http://127.0.0.1:8000/abc/def/ " ],
98+ [["" , "foo.jpg " ], "http://127.0.0.1:8000/foo.jpg " ],
99+ [["dir " , "0 " , "a.jpg " ], "http://127.0.0.1:8000/dir/0/a.jpg " ],
100+ ];
101+ }
102+
103+ #[DataProvider("URLComponentProvider " )]
104+ public function testGetURL (array $ relative_url_components , string $ expected )
105+ {
106+ $ this ->assertEquals ($ expected , getURL (...$ relative_url_components ));
107+ }
83108}
0 commit comments