Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Ignore query string in path configuration patterns? #248

Closed
frederfred opened this issue Oct 28, 2022 · 4 comments
Closed

Ignore query string in path configuration patterns? #248

frederfred opened this issue Oct 28, 2022 · 4 comments

Comments

@frederfred
Copy link

Hi,

I'm wondering if there is a possibility for patterns set in the path configuration config to ignore query strings?

Our use case is that we have one start location for a tab, e.g. /some-path?initial_visit=true, that we then replace with another location for any further visits (just using /some-path). Right now our config looks something like this, which works, but feels a little bit awkward:

{
  
  "patterns": [
    "^/some-path(\\?start=true)?$"
  ]
  
}

Maybe adding an option like "ignore_query_string": true in the properties object could be an idea?

Many thanks for providing this framework :)

@jayohms
Copy link
Collaborator

jayohms commented Oct 28, 2022

Path patterns use normal regular expressions, so we won't be modifying how regex's are evaluated. However, maybe this is helpful? #178

@frederfred
Copy link
Author

Thanks, and sorry for keeping the issue open for long. I forgot about it 🙃

Right now, I'm ignoring any query string in the pattern by doing this:

"patterns": [
  "^/some-path(\\?.*)?$",
],
"properties": {}

I haven't really figured out what "query_string_presentation": "replace" does, but are you saying that this configuration would produce the same result, ignoring any query string in the path?

"patterns": [
  "^/some-path",
],
"properties": {
  "query_string_presentation": "replace"
}

@jayohms
Copy link
Collaborator

jayohms commented Feb 21, 2023

If you have "query_string_presentation": "replace" configured for your path, it will allow all /some-path* visits (with or without a query string) to act as "replace" visits — meaning that each subsequent /some-path* visit will not push a new destination onto the backstack.

Where we find this helpful at 37signals is when a page contains a content-filter feature, like a drop-down <select> menu. Selecting a new option updates the url with a new query string filter and the current destination is reloaded without adding a new destination onto the backstack.

@frederfred
Copy link
Author

Ah, thanks for clarifying that. Then I believe I have to live with "^/some-path(\\?.*)?$" patterns because this used for specifying what fragment I would like to end up on.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Development

No branches or pull requests

2 participants