@@ -115,6 +115,30 @@ class WordPressOrgRestApiTests: XCTestCase {
115115 let _ = await api. get ( path: " /wp/v2/hello " , type: AnyResponse . self)
116116 XCTAssertEqual ( request? . url? . absoluteString, " http://localhost:8000/wp/v2/sites/1001/hello " )
117117 }
118+
119+ // Gutenberg Editor in the WordPress app may call `WordPressOrgRestApi` with a 'path' parameter that contain path
120+ // and query. This unit test ensures WordPressKit doesn't break that feature.
121+ func testPathWithQuery( ) async {
122+ var request : URLRequest ?
123+ stub ( condition: { _ in true } , response: {
124+ request = $0
125+ return HTTPStubsResponse ( error: URLError ( . networkConnectionLost) )
126+ } )
127+
128+ let api = WordPressOrgRestApi ( site: . dotCom( siteID: 1001 , bearerToken: " fakeToken " ) )
129+
130+ let _ = await api. get ( path: " /wp/v2/get-decodable?context=mobile " , type: AnyResponse . self)
131+ XCTAssertEqual ( request? . url? . absoluteString, " https://public-api.wordpress.com/wp/v2/sites/1001/get-decodable?context=mobile " )
132+
133+ let _ = await api. post ( path: " /wp/v2/post-decodable?context=mobile " , type: AnyResponse . self)
134+ XCTAssertEqual ( request? . url? . absoluteString, " https://public-api.wordpress.com/wp/v2/sites/1001/post-decodable?context=mobile " )
135+
136+ let _ = await api. get ( path: " /wp/v2/get-any-json?context=mobile " )
137+ XCTAssertEqual ( request? . url? . absoluteString, " https://public-api.wordpress.com/wp/v2/sites/1001/get-any-json?context=mobile " )
138+
139+ let _ = await api. post ( path: " /wp/v2/post-any-json?context=mobile " )
140+ XCTAssertEqual ( request? . url? . absoluteString, " https://public-api.wordpress.com/wp/v2/sites/1001/post-any-json?context=mobile " )
141+ }
118142}
119143
120144extension WordPressOrgRestApi {
0 commit comments