-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for query parameters in the PathConfiguration #190
Conversation
@jayohms, this is ready for review now having moved to a global configuration, only. I'd love your feedback on the naming of the configuration option. I nested it under a new sub-class which makes sense to me: Turbo.config.pathConfiguration.matchQuery = true But I'm open to keeping it one level deep and using: Turbo.config.matchPathConfigurationQuery = true Or something similar/cleaner. |
Thanks a lot for your commits @joemasilotti! One question though: Would you be open to the idea of enabling this feature by default to align the behavior? What are your thoughts on this? |
By default, the path configuration only looks at the path component of the URL. Enable query matching via: | ||
|
||
```swift | ||
Turbo.config.pathConfiguration.matchQuery = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turbo.config.pathConfiguration.matchQuery = true | |
Turbo.config.pathConfiguration.matchQueryStrings = true |
public func properties(for url: URL) -> PathProperties { | ||
properties(for: url.path) | ||
if Turbo.config.pathConfiguration.matchQuery, let query = url.query { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if Turbo.config.pathConfiguration.matchQuery, let query = url.query { | |
if Turbo.config.pathConfiguration.matchQueryStrings, let query = url.query { |
|
||
public extension TurboConfig { | ||
class PathConfiguration { | ||
public var matchQuery = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public var matchQuery = false | |
public var matchQueryStrings = false |
I'd say the only reason we're adding the new configuration option is so we avoid breaking existing apps. Otherwise, I'd be in favor of always matching patterns against path + query strings. So, let's avoid breaking apps on both platforms and keep the default behaviors in place. We have upcoming changes later this year to make make the libraries easier to use out-of-the-box with sane defaults, so that'll be a good time to reevaluate the defaults. |
closes #188