Skip to content

Commit

Permalink
Change config option from matchQuery -> matchQueryStrings
Browse files Browse the repository at this point in the history
  • Loading branch information
jayohms committed Mar 22, 2024
1 parent 29414c5 commit c961266
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Docs/PathConfiguration.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ When the `Session` proposes a visit, it looks up the path properties for the pro
By default, path patterns only match against the path component of the URL. Enable query string matching via:

```swift
Turbo.config.pathConfiguration.matchQuery = true
Turbo.config.pathConfiguration.matchQueryStrings = true
```

To ensure the order of query string parameters don't affect matching, a wildcard `.*` before and after the match is recommended, like so:
Expand Down
2 changes: 1 addition & 1 deletion Source/Path Configuration/PathConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public final class PathConfiguration {

/// Returns a merged dictionary containing all the properties that match this URL.
public func properties(for url: URL) -> PathProperties {
if Turbo.config.pathConfiguration.matchQuery, let query = url.query {
if Turbo.config.pathConfiguration.matchQueryStrings, let query = url.query {
return properties(for: "\(url.path)?\(query)")
}
return properties(for: url.path)
Expand Down
2 changes: 1 addition & 1 deletion Source/Turbo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ public class TurboConfig {

public extension TurboConfig {
class PathConfiguration {
public var matchQuery = false
public var matchQueryStrings = false
}
}
4 changes: 2 additions & 2 deletions Tests/PathConfigurationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ class PathConfigurationTests: XCTestCase {
func test_propertiesForURL_withParams() {
let url = URL(string: "http://turbo.test/sample.pdf?open_in_external_browser=true")!

Turbo.config.pathConfiguration.matchQuery = false
Turbo.config.pathConfiguration.matchQueryStrings = false
XCTAssertEqual(configuration.properties(for: url), [:])

Turbo.config.pathConfiguration.matchQuery = true
Turbo.config.pathConfiguration.matchQueryStrings = true
XCTAssertEqual(configuration.properties(for: url), [
"open_in_external_browser": true
])
Expand Down

0 comments on commit c961266

Please sign in to comment.