@@ -40,6 +40,46 @@ describe("buildUrl", () => {
4040 } ) ;
4141 } ) ;
4242
43+ describe ( "IP address URLs" , ( ) => {
44+ it ( "should handle IP address with path" , ( ) => {
45+ const result = buildUrl ( "http://159.223.72.31/api" , [ "users" ] ) ;
46+ expect ( result ) . toBe ( "http://159.223.72.31/api/users" ) ;
47+ } ) ;
48+
49+ it ( "should handle IP address with path and multiple segments" , ( ) => {
50+ const result = buildUrl ( "http://159.223.72.31/api" , [ "users" , "123" ] ) ;
51+ expect ( result ) . toBe ( "http://159.223.72.31/api/users/123" ) ;
52+ } ) ;
53+
54+ it ( "should handle IP address with port and path" , ( ) => {
55+ const result = buildUrl ( "http://192.168.1.1:8080/api" , [ "posts" ] ) ;
56+ expect ( result ) . toBe ( "http://192.168.1.1:8080/api/posts" ) ;
57+ } ) ;
58+
59+ it ( "should handle IP address with empty path array" , ( ) => {
60+ const result = buildUrl ( "http://159.223.72.31/api" , [ ] ) ;
61+ expect ( result ) . toBe ( "http://159.223.72.31/api/" ) ;
62+ } ) ;
63+
64+ it ( "should handle IP address with query parameters" , ( ) => {
65+ const result = buildUrl ( "http://159.223.72.31/api" , [ "users" ] , {
66+ page : 1 ,
67+ limit : 10 ,
68+ } ) ;
69+ expect ( result ) . toBe ( "http://159.223.72.31/api/users?page=1&limit=10" ) ;
70+ } ) ;
71+
72+ it ( "should handle localhost IP with path" , ( ) => {
73+ const result = buildUrl ( "http://127.0.0.1:3000/api" , [ "health" ] ) ;
74+ expect ( result ) . toBe ( "http://127.0.0.1:3000/api/health" ) ;
75+ } ) ;
76+
77+ it ( "should handle IP address with nested api path" , ( ) => {
78+ const result = buildUrl ( "http://10.0.0.1/v1/api" , [ "resources" , "items" ] ) ;
79+ expect ( result ) . toBe ( "http://10.0.0.1/v1/api/resources/items" ) ;
80+ } ) ;
81+ } ) ;
82+
4383 describe ( "relative paths" , ( ) => {
4484 it ( "should handle relative base without leading slash" , ( ) => {
4585 const result = buildUrl ( "api" , [ "users" ] ) ;
0 commit comments