fasthtml icon indicating copy to clipboard operation
fasthtml copied to clipboard

[BUG] uri method renders wrong path

Open andree0 opened this issue 4 months ago • 1 comments

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)
  • [x] I have provided a minimal reproducible example
  • [x] I have included the versions of fastlite, fastcore, and fasthtml
  • [x] I understand that this is a volunteer open source project with no commercial support.

andree0 avatar Jul 30 '25 09:07 andree0