diff options
author | Artur Malabarba <bruce.connor.am@gmail.com> | 2014-11-29 20:02:14 +0000 |
---|---|---|
committer | Artur Malabarba <bruce.connor.am@gmail.com> | 2014-11-29 20:02:14 +0000 |
commit | 69b90717fb304958be8aabe6c3d02199293b27b4 (patch) | |
tree | cc707dd328a37c89c8394ba8d97cc04d5554f530 | |
parent | 9a39c5d985423e3675cfcd56cf951bb3ab283147 (diff) |
New sx--shorten-url function in sx.el
-rw-r--r-- | sx.el | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -173,6 +173,21 @@ would yield cons-cell)))) data)))) +(defun sx--shorten-url (url) + "Shorten URL hiding anything other than the domain. +Paths after the domain are replaced with \"...\". +Anything before the (sub)domain is removed." + (replace-regexp-in-string + ;; Remove anything after domain. + (rx (group-n 1 (and (1+ (any word ".")) "/")) + (1+ anything) string-end) + (eval-when-compile + (concat "\\1" (if (char-displayable-p ?…) "…" "..."))) + ;; Remove anything before subdomain. + (replace-regexp-in-string + (rx string-start (or (and (0+ word) (optional ":") "//"))) + "" url))) + ;;; Printing request data (defvar sx--overlays nil |