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

issue: urlbuilder requires scheme #4

Open
a-h opened this issue Sep 24, 2024 · 2 comments
Open

issue: urlbuilder requires scheme #4

a-h opened this issue Sep 24, 2024 · 2 comments

Comments

@a-h
Copy link
Contributor

a-h commented Sep 24, 2024

In my first use of the URL builder, I wanted to create a URL within a site and add a query string. I don't care about the scheme or host.

e.g. I wanted to do something like this:

<div hx-ext="sse" sse-connect={ urlbuilder.Path("/chat/response").Query("input", text) } sse-swap="message">

However, the API forces you to have a scheme and host.

Maybe the API should have something like urlbuilder.Path, urlbuilder.Scheme etc. which returns a builder? Not sure, but the ergonomics didn't quite work out.

@garrettladley - ideas?

@a-h
Copy link
Contributor Author

a-h commented Sep 24, 2024

I also noted that the response was sanitized, despite using the builder.

So the input:

<div hx-ext="sse" sse-connect={ string(urlbuilder.New("", "").Path("/chat/response").Query("prompt", prompt).Build()) } sse-swap="message"></div>

Gave me the following:

about:invalid#TemplFailedSanitizationURL

Because of the call to templ.URL to create the safe URL, which sanitizes the inputs.

It's probably because the scheme etc was empty, so there's something funky in the output.

@garrettladley
Copy link
Contributor

I like the idea of having urlbuilder.Path, urlbuilder.Scheme etc return a builder. The reason I initially forced urlbuilder.New(...) to accept a schema and host was to ensure it would pass the schema and protocol checks in templ.URL.

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

No branches or pull requests

2 participants