@@ -11,6 +11,7 @@ import {
1111} from "./lib/in-memory-cli" ;
1212import { makeTmpDir } from "./lib/terminal" ;
1313import {
14+ appendSubpath ,
1415 setupSlackApp ,
1516 updateEnvCredentials ,
1617 verifySlackSignature ,
@@ -111,6 +112,44 @@ describe("verifySlackSignature", () => {
111112 } ) ;
112113} ) ;
113114
115+ describe ( "appendSubpath" , ( ) => {
116+ it ( "should append a subpath to a simple URL" , ( ) => {
117+ expect ( appendSubpath ( "https://example.com" , "/slack" ) ) . toBe (
118+ "https://example.com/slack"
119+ ) ;
120+ } ) ;
121+
122+ it ( "should append a subpath to a URL with an existing path" , ( ) => {
123+ expect ( appendSubpath ( "https://example.com/devhook/abc" , "/slack" ) ) . toBe (
124+ "https://example.com/devhook/abc/slack"
125+ ) ;
126+ } ) ;
127+
128+ it ( "should handle trailing slashes on the base URL" , ( ) => {
129+ expect ( appendSubpath ( "https://example.com/devhook/" , "/slack" ) ) . toBe (
130+ "https://example.com/devhook/slack"
131+ ) ;
132+ } ) ;
133+
134+ it ( "should handle subpath without leading slash" , ( ) => {
135+ expect ( appendSubpath ( "https://example.com/devhook" , "slack" ) ) . toBe (
136+ "https://example.com/devhook/slack"
137+ ) ;
138+ } ) ;
139+
140+ it ( "should handle both trailing and leading slashes" , ( ) => {
141+ expect ( appendSubpath ( "https://example.com/devhook///" , "///slack" ) ) . toBe (
142+ "https://example.com/devhook/slack"
143+ ) ;
144+ } ) ;
145+
146+ it ( "should preserve query parameters" , ( ) => {
147+ expect (
148+ appendSubpath ( "https://example.com/devhook?token=abc" , "/slack" )
149+ ) . toBe ( "https://example.com/devhook/slack?token=abc" ) ;
150+ } ) ;
151+ } ) ;
152+
114153describe ( "updateEnvCredentials" , ( ) => {
115154 it ( "should add credentials to an empty env file" , async ( ) => {
116155 await using tempDir = await makeTmpDir ( ) ;
0 commit comments