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

Several implementions of a single URL abstraction #3479

Open
aadcg opened this issue Aug 23, 2024 · 1 comment
Open

Several implementions of a single URL abstraction #3479

aadcg opened this issue Aug 23, 2024 · 1 comment
Labels
4-series Related to releases whose major version is 4.

Comments

@aadcg
Copy link
Member

aadcg commented Aug 23, 2024

As to ensure that convert strings to quri:uri objects, we have defined:

  • url methods for strings and quri:uri
  • ensure-url
  • string->url
  • strings->urls

Also we have defined the type url-designator, as to accommodate that a URL may be of type quri:uri or string, but that seems a bit premature.

@aadcg aadcg added the 4-series Related to releases whose major version is 4. label Aug 23, 2024
@aadcg
Copy link
Member Author

aadcg commented Aug 27, 2024

Partially addressed in 94802b9 and bdcf23e.


A deeper refactor is needed but I'll postpone it since it is a long refactor that may break some functionality (special care is needed).

The idea is simple. Define the routine below and delete the url methods that specialize over string and quri:uri.

(defun coerce-to-url (url-designator)
  "Ensure URL-DESIGNATOR is of type `quri:uri'."
  (typecase url-designator
    (string (quri:uri url-designator))
    (quri:uri url-designator)))

Redefine the url-designator type as below.

(deftype url-designator ()
  "A URL designator type is either a string or a `quri:uri'."
  `(or string quri:uri))

These 2 ideas will enable refactoring the following odd idiom,

(defun url-util (url) (let ((url (url url))) url))

into:

(defun url-util (url-designator) (let ((url (coerce-to-url url-designator))) url))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4-series Related to releases whose major version is 4.
Development

No branches or pull requests

1 participant