Skip to content

Unify queryMap methods, fix diffent behaviour and edge cases #13223

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mkurz
Copy link
Member

@mkurz mkurz commented Mar 28, 2025

...WORK IN PROGRESS...

I am not working on this right now, I am just pushing things I tried a couple of days ago.
No one complained yet and I think it's not so super important right now because some edge cases are really total edge cases.

Like said in that comment we use a different logic to create the query map and in some cases the methods behave slightly different. Of course it would be better if all methods use the same logic/method.

Test code for sample app to test locally

Java action:

    public Result index(Http.Request request) {
        System.out.println();
        System.out.println("one:" + request.queryString("one"));
        System.out.println("two:" + request.queryString("two"));
        System.out.println("three:" + request.queryString("three"));
        System.out.println("empty:" + request.queryString(""));
        return ok(
        "one:" + request.queryString("one") + "<br>" +
                "one?+" + request.queryString("one?+") + "<br>" +
                "two:" + request.queryString("two") + "<br>" +
                "two=:" + request.queryString("two=") + "<br>" +
                "three:" + request.queryString("three") + "<br>" +
                "empty:" + request.queryString("") + "<br>" +
                "empty_all:" + Arrays.stream(request.queryString().getOrDefault("", new String[]{"<empty>"})).collect(Collectors.joining(","))
        ).as("text/html");

Equivalent Scala action:

  def index() = Action { implicit request: Request[AnyContent] =>
    println()
    println("one:" + request.getQueryString("one"))
    println("two:" + request.getQueryString("two"))
    println("three:" + request.getQueryString("three"))
    println("empty:" + request.getQueryString(""))
    Ok(
        "one:" + request.getQueryString("one") + "<br>" +
        "one?+:" + request.getQueryString("one?+") + "<br>" +
        "two:" + request.getQueryString("two") + "<br>" +
        "two=:" + request.getQueryString("two=") + "<br>" +
        "three:" + request.getQueryString("three") + "<br>" +
        "empty:" + request.getQueryString("") + "<br>" +
         "empty_all:" + request.queryString.get("").map(_.mkString(","))
    ).as("text/html");
  }

Testing with:

http://localhost:9000/?one=&two=a+b&
http://localhost:9000/?one&two=a+b&
http://localhost:9000/?one=&two=a+b&=
http://localhost:9000/?one&two=a+b
http://localhost:9000/?one?%2B=&two%3D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant