Skip to content

Commit

Permalink
Merge pull request #146 from areina/fix-145
Browse files Browse the repository at this point in the history
Remove <dash_entry_.*> from documentation urls
  • Loading branch information
areina committed Dec 7, 2016
2 parents 414e2a1 + 58e117d commit 351051e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 5 additions & 4 deletions helm-dash.el
Original file line number Diff line number Diff line change
Expand Up @@ -458,10 +458,11 @@ candidate opts."
(list (car docset) row)))

(defun helm-dash-result-url (docset-name filename &optional anchor)
"Return the full, absolute URL to documentation: either a file:/// URL joining
DOCSET-NAME, FILENAME & ANCHOR with sanitization of spaces or a http(s):// URL
formed as-is if FILENAME is a full HTTP(S) URL."
(let ((path (format "%s%s" filename (if anchor (format "#%s" anchor) ""))))
"Return the full, absolute URL to documentation.
Either a file:/// URL joining DOCSET-NAME, FILENAME & ANCHOR with sanitization
of spaces or a http(s):// URL formed as-is if FILENAME is a full HTTP(S) URL."
(let* ((clean-filename (replace-regexp-in-string "<dash_entry_.*>" "" filename))
(path (format "%s%s" clean-filename (if anchor (format "#%s" anchor) ""))))
(if (string-match-p "^https?://" path)
path
(replace-regexp-in-string
Expand Down
4 changes: 4 additions & 0 deletions test/helm-dash-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@
(should (string-match-p "Documents/three#anchor$"
(helm-dash-result-url "Redis" "three#anchor"))))

(ert-deftest helm-dash-result-url/remove-dash-entry-tag-from-url ()
(should (string-match-p "Documents/three#anchor$"
(helm-dash-result-url "Python 3" "three<dash_entry_menuDescription=android.provider.ContactsContract.CommonDataKinds.Website>" "anchor"))))

;;;; helm-dash-docsets-path

(ert-deftest helm-dash-docsets-path-test/relative-path ()
Expand Down

0 comments on commit 351051e

Please sign in to comment.