Skip to content

[BUG] uri method renders wrong path #764

@andree0

Description

@andree0

Describe the bug
uri method renders wrong path to endpoint, name arg of route contains _ but path of this endpoint contains -, uri method returns path with _ and request to it returns 404 HTTP code

Minimal Reproducible Example

from fasthtml import common as fh

app, rt = fh.fast_app(live=True)

@rt("/update-remaining-limits", name="update_remaining_limits")
async def get(
    htmx: fh.HtmxHeaders, _added: int = 0, _max: int = 0, _used: int = 0
):
    return max(0, _max - _used + _added)

@rt("/")
def index():
    return fh.uri("update_remaining_limits", _added=10, _max=30, _used=0)  # ---> update_remaining_limits/_added=10&_max=30&_used=0

fh.serve()

Expected behavior
It shoud be fh.uri("update_remaining_limits") # ---> /update-remaining-limits (with - instaed of _)
in accordance with the documentation https://fastht.ml/docs/ref/handlers.html#path-and-query-parameters

Environment Information

  • fastlite version: 0.1.3
  • fastcore version: 1.8.1
  • fasthtml version: 0.12.22

Confirmation

  • I have read the FAQ (https://docs.fastht.ml/explains/faq.html)
  • I have provided a minimal reproducible example
  • I have included the versions of fastlite, fastcore, and fasthtml
  • I understand that this is a volunteer open source project with no commercial support.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions