Yeah. That's really similar and would help in my usecase as well.

I don't know what it currently does, as I am not experienced enough to read
(or even write) the source code (in that detail).

Would it be architectural a challenge to move URL/Domain parsing to the
beginning of the command parsing?

For example in JS I'd probably do an
(Heavily abstracted, ofc that flow is way more complex)

function handleURL(url, args) {
  const parsedURL= new URL(url)
  // Parsing url first
  const config = await Bun.file(".curlrc").then(file => {
    return parseConfig({
      domain: parsedURL.hostname,
      configFileHandle: file
    })
  }
}

Or something.
Especially since the URL that is passed is not dynamic, except for the path
part when globbing is used.
Or can the domain part also be dynamic with globbing?

Other than that, the domain should be static from what I know and could be
parsed in the beginning of the internal flow.
The parsing of the URL is not dependent of the config itself, as no config
(or argument) setting allows for modifications of the passed URL, right?

At what point are the variables for write-out calculated? Maybe those could
partially be calculated earlier, if it doesn't fragment the code too much.

Which would also work with multiple urls.
And then providing the parsed url variables either as env vars or as
internal variable to the following parser.

On Thu, 11 Dec 2025, 13:04 Daniel Stenberg, <[email protected]> wrote:

> On Thu, 11 Dec 2025, Bastian Jesuiter via curl-users wrote:
>
> > The curlrc would include the a header with a {{ domain }} like variable
> > syntax.
> >
> > Like:
> > header @path/{{domain}}.txt
> >
> > Where the domain will be inferred by the given domain in the command.
>
> I like this idea! Let me also mention that we have a similar idea listed
> in
> the TODO:
>
>    https://curl.se/docs/todo.html#hostname-sections-in-config-files
>
> It would get roughly the same thing with a syntax like this:
>
> [domain]
>    header @path/special.txt
>
> I think both takes could be worth exploring. They have roughly the same
> challenge: they make it necessary to parse the config file (again?) after
> each
> URL has been retrieved, so that it knows the domain.
>
> --
>
>   / daniel.haxx.se || https://rock-solid.curl.dev
>
-- 
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-users
Etiquette:   https://curl.se/mail/etiquette.html

Reply via email to