Skip to content

Conversation

@EmileTrotignon
Copy link

@EmileTrotignon EmileTrotignon commented Oct 22, 2025

The function works in a weird way because apparently there no way to get an empty url object in javascript.

Also no more copying files around which should improve editor integration

(modes melange)
(public_name server-reason-react.url_js)
(libraries melange.js)
(wrapped false)
Copy link
Collaborator

@pedrobslisboa pedrobslisboa Oct 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot remove the wrapped false as it enables the library to function as "universal".

If you don't have it the usage becomes Url_js.Url instead of only Url, which missmatches with the native library Url_native.Url

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its still unwrapped because it implements url which is a unwrapped library. If you try to add it back you get an error message.

@@ -0,0 +1,5 @@
(library
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn't work with melange as it doesn't have the universal structure. Take a look here: https://ml-in-barcelona.github.io/server-reason-react/server-reason-react/how-to-organise-universal-code.html

Comment on lines +1 to +7
include URL_impl

let construct ?protocol ~hostname ?port ?pathname ?search ?hash ?password ?username () =
let apply_opt f o = match o with None -> Fun.id | Some x -> fun u -> f u x in
"https://example.com" |> makeExn |> apply_opt setProtocol protocol |> Fun.flip setHostname hostname
|> apply_opt setPort port |> apply_opt setPathname pathname |> apply_opt setSearch search |> apply_opt setHash hash
|> apply_opt setPassword password |> apply_opt setUsername username
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused about the motivation of this feature. Can you explain better in the PR description?

(library
(name url_native)
(public_name server-reason-react.url_native)
(wrapped false)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(pps melange.ppx))
(implements url))

(copy_files# "../URL.rei")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also don't like copy_files, but until we have the dune single-context feature, we need it.
(Related https://github.com/ml-in-barcelona/server-reason-react/pull/317/files#r2453920368)

@EmileTrotignon
Copy link
Author

I with trying to write tests and I stubbled on a lot of annoying issues, like protocol url being https: and not https, and the pathname being /path and not path.

Then reading the implementation I realised Uri was mostly what I wanted already, so I will probably use that.

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

Successfully merging this pull request may close these issues.

2 participants