@@ -24,6 +24,7 @@ import weaver.{FunSuiteIO, IOSuite}
2424import scala .concurrent .duration .*
2525import scala .scalajs .js .Promise
2626import smithy4s .http .HttpUri
27+ import org .scalajs .dom .URL
2728
2829object UnitTest extends FunSuiteIO :
2930 val uri =
@@ -73,6 +74,44 @@ object UnitTest extends FunSuiteIO:
7374 " https://localhost:9999/1/2/3"
7475 )
7576
77+ test(" Base URI with no path prefix" ):
78+ val result = smithy4s_fetch.SimpleRestJsonCodecs
79+ .toSmithy4sHttpUri(new URL (" http://localhost" ))
80+ .path
81+
82+ expect(result.isEmpty)
83+
84+ test(" Base URI with no path prefix (with slash)" ):
85+ val result = smithy4s_fetch.SimpleRestJsonCodecs
86+ .toSmithy4sHttpUri(new URL (" http://localhost/" ))
87+ .path
88+
89+ expect(result.isEmpty)
90+
91+ test(" Base URI with path prefix" ):
92+ expect.same(
93+ smithy4s_fetch.SimpleRestJsonCodecs
94+ .toSmithy4sHttpUri(new URL (" http://localhost/prefix" ))
95+ .path,
96+ IndexedSeq (" prefix" )
97+ )
98+
99+ test(" Base URI with no path prefix, including empty segments" ):
100+ expect.same(
101+ smithy4s_fetch.SimpleRestJsonCodecs
102+ .toSmithy4sHttpUri(new URL (" http://localhost/foo//bar//baz/" ))
103+ .path,
104+ IndexedSeq (" foo" , " " , " bar" , " " , " baz" )
105+ )
106+
107+ test(" Base URI with path prefix, trailing slash doesn't matter" ):
108+ expect.same(
109+ smithy4s_fetch.SimpleRestJsonCodecs
110+ .toSmithy4sHttpUri(new URL (" http://localhost/foo/" )),
111+ smithy4s_fetch.SimpleRestJsonCodecs
112+ .toSmithy4sHttpUri(new URL (" http://localhost/foo" ))
113+ )
114+
76115@ annotation.experimental
77116object IntegrationTest extends IOSuite :
78117 val service = API .service[IOService ]
0 commit comments