Function: forge--split-forge-url

forge--split-forge-url is a byte-compiled function defined in forge-core.el.

Signature

(forge--split-forge-url URL &optional RELAX)

Source Code

;; Defined in ~/.emacs.d/elpa/forge-20260408.1922/forge-core.el
(defun forge--split-forge-url (url &optional relax)
  (save-match-data
    (cond
      ((string-match
        (concat "\\`"
                "\\(?:git://\\|"
                "[^/@]+@\\|"
                "\\(?:ssh\\|ssh\\+git\\|git\\+ssh\\)://\\(?:[^/@]+@\\)?\\|"
                "https?://\\(?:[^/@]+@\\)?\\)?"
                (if relax
                    "\\(?1:[^:/]+\\)"
                  (regexp-opt (mapcar #'car forge-alist) t))
                "\\(?::[0-9]+\\)?"
                "\\(?:/\\|:/?\\)"
                "~?\\(?2:.+?\\)/"
                "\\(?3:[^/]+?\\)"
                "\\(?:\\.git\\|/\\)?"
                "\\'")
        url)
       (and-let ((elt (forge--get-forge-host (match-string 1 url) (not relax))))
         ;; Return the WEBHOST (not the GITHOST, URLs passed to this
         ;; function usually contain a GITHOST) because the IDs used to
         ;; identify a repository in the database are based on WEBHOSTs.
         (list (caddr elt)
               (match-string 2 url)
               (match-string 3 url))))
      ((not relax)
       ;; The host part didn't match any GITHOST in `forge-alist', but it
       ;; might be a ssh host alias.  We have to relax strictness; in the
       ;; extremely unlikely case that there is a common path between the
       ;; HOST and the OWNER for this forge, we would incorrectly end up
       ;; making that path part of the owner.
       (forge--split-forge-url url t)))))