Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ _None._

### Bug Fixes

_None._
- Fix crash when querying a WordPress plugin whose slug is not url-safe. [#767]

### Internal Changes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public struct PluginDirectoryGetInformationEndpoint {

func buildRequest() throws -> URLRequest {
try HTTPRequestBuilder(url: PluginDirectoryRemoteConstants.getInformationEndpoint)
.append(percentEncodedPath: "\(slug).json")
.appendURLString("\(slug).json")
.query(name: "fields", value: "icons,banners")
.build()
}
Expand Down
12 changes: 12 additions & 0 deletions Tests/WordPressKitTests/Tests/PluginDirectoryTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -343,4 +343,16 @@ class PluginDirectoryTests: XCTestCase {

XCTAssertTrue(lhs == rhs)
}

func testUnconventionalPluginSlug() async throws {
let data = try MockPluginDirectoryProvider.getPluginDirectoryMockData(with: "plugin-directory-rename-xml-rpc", sender: type(of: self))
stub(condition: isHost("api.wordpress.org")) { _ in
HTTPStubsResponse(data: data, statusCode: 200, headers: ["Content-Type": "application/json"])
}

let _ = try await PluginDirectoryServiceRemote().getPluginInformation(slug: "%-is-not-allowed")
let _ = try await PluginDirectoryServiceRemote().getPluginInformation(slug: "中文")

// No assertion needed.
}
}