Skip to content

Conversation

@cuihtlauac
Copy link
Collaborator

  • Remove old Url.package
  • Rename old Url.package_with_version into Url.package
  • Update Url.with_version
    • None -> "/latest" (as in old Url.package_with_version)
    • Some "" -> "" (as in old Url.package)
    • Some x -> "/x" (as in old Url.package_with_version)
  • Use new Url.with_version in new Url.package
  • At call sites of old Url.package, add ~version:"" to get the
    same behaviour
  • At call sites of old Url.package_with_version, replace by Url.package

A bit convoluted, but did not managed to observe a change of behaviour.

Comment on lines 7 to 10
let with_version = Option.fold ~none:"/latest" ~some:(fun v -> if v = "" then v else "/" ^ v)

let package_with_version ?version ?hash v =
with_hash hash ^ "/" ^ v ^ "/" ^ with_version version
let package ?version ?hash v =
with_hash hash ^ "/" ^ v ^ with_version version
Copy link
Collaborator

Choose a reason for hiding this comment

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

IMO all the URLs that only redirect somewhere else should be separate from those intended for use in templates.

So, for URLs used in the templates and as redirection target, we should always require either a version or "latest".

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I had something along those lines in mind as a second stage/commit. It makes sense to use an optional argument

  • Avoids writing Some
  • Avoids passing None

Since there are three cases: specific, latest and not specified; there are two possible implementations:

  1. None for latest and Some "" for not specified
  2. None for not specified and Some "latest" for latest

I picked the first because it was the implicit one earlier. Do you thing we should go for the second or do you have another idea?

Copy link
Collaborator

@sabine sabine Feb 24, 2023

Choose a reason for hiding this comment

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

No, I think we should make sure that we never use /p/PACKAGE-URLs in the templates and that this also cannot happen by accident.

So, there should be:

  • one function that renders a package URL (which always is either a versioned URL /p/package/VERSION or latest-URL /p/PACKAGE/latest)
  • one redirect /p/PACKAGE -> /p/PACKAGE/latest

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, I think we should make sure that we never use /p/PACKAGE-URLs in the templates and that this also cannot happen by accident.

Then we need to update dependencies and conflicts in package overview, it's happening there :-)

  • one function that renders a package URL (which always is either a versioned URL /p/package/VERSION or latest-URL /p/PACKAGE/latest)

Let's see what I can do.

* Remove old Url.package
* Rename old Url.package_with_version into Url.package
* Update Url.with_version
  - None -> "/latest" (as in old Url.package_with_version)
  - Some "" -> "" (as in old Url.package)
  - Some x -> "/x" (as in old Url.package_with_version)
* Use new Url.with_version in new Url.package
* At call sites of old Url.package, add ~version:"" to get the
  same behaviour
* At call sites of old Url.package_with_version, replace by Url.package

A bit convoluted, but did not managed to observe a change of behaviour.
@cuihtlauac
Copy link
Collaborator Author

Subsumed by #999

@cuihtlauac cuihtlauac closed this Mar 22, 2023
@cuihtlauac cuihtlauac deleted the url-tweaks branch April 4, 2023 08:04
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