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 defcustom to configure a path between host and filename #92

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion browse-at-remote.el
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ By default is true."
"List of domains where the web URL should be http."
:type '(repeat string))

(defcustom browse-at-remote-append-path-to-host nil
"Path to append at the end of the HTTP host before the filename name."
:type 'string
:group 'browse-at-remote)

(defun browse-at-remote--get-url-from-remote (remote-url)
"Return (DOMAIN . URL) from REMOTE-URL."
;; If the protocol isn't specified, git treats it as an SSH URL.
Expand All @@ -107,6 +112,7 @@ By default is true."
(port (url-port-if-non-default parsed))
(web-proto
(if (equal (url-type parsed) "http") "http" "https"))
(path (or browse-at-remote-append-path-to-host ""))
(filename (url-filename parsed)))
;; SSH URLs can contain colons in the host part, e.g. ssh://example.com:foo.
(when (s-contains-p ":" host)
Expand All @@ -124,7 +130,7 @@ By default is true."
(when port
(setq host (format "%s:%d" host port)))
(cons host
(format "%s://%s%s" web-proto host filename))))
(format "%s://%s%s%s" web-proto host path filename))))

(defun browse-at-remote--remote-ref (&optional filename)
"Return (REMOTE-URL . REF) which contains FILENAME.
Expand Down