Skip to content

feat(urlMatcherFactory): add support for dot notation in query parameters #1718

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

Closed
wants to merge 2 commits into from

Conversation

drgould
Copy link

@drgould drgould commented Jan 30, 2015

I have a use case for using dot notated query parameters (e.g. ?foo.bar=baz) and I noticed support was lacking from ui-router. As far as I can tell there is nothing that restricts dot notation in urls.

As part of this, it now recreates the implied structure for dot notated parameters. So "?foo.bar=baz" will result in $stateParams being: { "foo": { "bar": "baz" } }

…ters

Add support for specifying query parameters using object dot notation (i.e. ?foo.bar)
Change $stateParams to mimic object structure defined in dot notated query parameters.
For example, given the state url "/user/?foo.bar" and the url fragment "/user/?foo.bar=baz"
$stateParams will be: { "foo": { "bar": "baz" } }
@nateabele
Copy link
Contributor

Seems a little out there. Not sure how I feel about it. @christopherthielen?

Also, you committed release files.

@drgould
Copy link
Author

drgould commented Jan 30, 2015

Sorry, forgot github automatically pulls in commits until the PR is merged. I took out the "release" commit.

@christopherthielen
Copy link
Contributor

I have no problem with supporting dots in param names, but the value being expanded into an object based on the param name feels really odd and unexpected to me.

I can't think of the use case that couldn't be solved in other ways. @drgould what kind of params are you doing this with, and why expand the object out?

@drgould
Copy link
Author

drgould commented Jan 31, 2015

I mainly need it for namespacing. We expose certain options that can be changed via query params. A few examples: embedded.showNavigation and theme.headerFontColor
It would be a lot easier if ui-router automatically created objects out of them so we could apply the options with a simple $scope.opts.theme = $stateParams.theme rather than each option separately (there are a lot).

Maybe it could be something separate as to not drastically change the current function of $stateParams?

@nateabele
Copy link
Contributor

Maybe it could be something separate as to not drastically change the current function of $stateParams?

Yeah, I feel like maybe a mapping layer that sits between $location.search() and UrlMatcher would be more appropriate/flexible.

@drgould
Copy link
Author

drgould commented Mar 6, 2015

I took out the object conversion so this can get merged in while I investigate a better way to do the conversion.

@stale
Copy link

stale bot commented Jan 24, 2020

This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs.

This does not mean that the issue is invalid. Valid issues
may be reopened.

Thank you for your contributions.

@stale stale bot added the stale label Jan 24, 2020
@stale stale bot closed this Feb 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants