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

Add schemeless-url helper? #73

Open
Ambrevar opened this issue Oct 31, 2022 · 2 comments
Open

Add schemeless-url helper? #73

Ambrevar opened this issue Oct 31, 2022 · 2 comments

Comments

@Ambrevar
Copy link
Collaborator

It's often useful to get the URL string without its scheme, but Quri makes it surprisingly difficult. Maybe add a helper?

(defun schemeless-url (url)             ; Inspired by `quri:render-uri'.
  "Return URL without its scheme (e.g. it removes 'https://')."
  ;; Warning: We can't just set `quri:uri-scheme' to nil because that would
  ;; change the port (e.g. HTTP defaults to 80, HTTPS to 443).
  (format nil
          "~@[~A~]~@[~A~]~@[?~A~]~@[#~A~]"
          (quri:uri-authority url)
          (or (quri:uri-path url) "/")
          (quri:uri-query url)
          (quri:uri-fragment url)))
@Ambrevar
Copy link
Collaborator Author

Maybe better:

  • copy the URL,
  • if the port is NIL set it to the default value for the given scheme
  • set the scheme to NIL

@aadcg
Copy link
Collaborator

aadcg commented Oct 31, 2022

The second approach seems sounder.

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