Skip to content
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 built-in urlquery.decode_object function #2647

Closed
scevallos opened this issue Aug 20, 2020 · 1 comment · Fixed by #2670
Closed

Add built-in urlquery.decode_object function #2647

scevallos opened this issue Aug 20, 2020 · 1 comment · Fixed by #2670

Comments

@scevallos
Copy link
Contributor

Expected Behavior

> urlquery.decode_object("?pizza=good&coffee=great&dogs=best")
{
    "pizza": "good",
    "coffee": "great",
    "dogs": "best"
}

Actual Behavior

There is no such function currently. Although, we do have the inverse function available as urlquery.encode_object. This would be helpful for policies that need to make use of URI query parameters.

This is a feature request for such a function to be added.

@tsandall
Copy link
Member

The built-in function should deal with cases where the same parameter is specified multiple times. Usually this is handled by returning the values as an array:

urlquery.decode_object("?pizza=good&coffee=great&dogs=best&coffee=mandatory")
{
    "pizza": ["good"],
    "coffee": ["great","mandatory"],
    "dogs": ["best"]
}

GBrawl added a commit to GBrawl/opa that referenced this issue Aug 30, 2020
This builtin is the reverse of the encode_object builtin and
makes it easier to use the URI query parameters in policies

Fixes open-policy-agent#2647

Signed-off-by: Frederic <frederic.vanreet@icloud.com>
tsandall pushed a commit that referenced this issue Aug 31, 2020
This builtin is the reverse of the encode_object builtin and
makes it easier to use the URI query parameters in policies

Fixes #2647

Signed-off-by: Frederic <frederic.vanreet@icloud.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants