Skip to content

String "true" not treated as boolean true in query params #4261

Open
@xzyingxiashubro

Description

@xzyingxiashubro

Describe the bug

The parseBoolean function used in this project is designed to deal with both string and bool "true". However, in the real api, it appears to only recognize unquoted true (i.e. ?show_icons=true) but not quoted strings (i.e. ?show_icons="true"), which seems inconsistent with its intended design.

Try using the API with the following query:
https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons="true"

Expected behavior

It is expectet to have the same behavior as bool true, but the html rendering seemed not as fellow:

Screenshots / Live demo link

Image

Additional context

I have check the code about parseBoolean and find the solution about string, so I am wonder abou why.

As a minor suggestion for improved robustness:
Would it be possible to apply trimming to boolean-like query string values such as " true " or "false "?
This could help prevent subtle bugs caused by extra spaces, especially when users dynamically construct URLs.

Thanks again for the great work!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions