From 9bcecb2f4f822d438ae8fbaf675d37ff3ac46943 Mon Sep 17 00:00:00 2001 From: malc Date: Sat, 27 Jun 2015 00:26:10 +0300 Subject: [PATCH] Move geturl to utils and add https as a valid scheme --- config.ml | 27 --------------------------- utils.ml | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/config.ml b/config.ml index ce92cde..2ecdf1f 100644 --- a/config.ml +++ b/config.ml @@ -484,33 +484,6 @@ let version () = Help.version (fz_version ()) Sys.ocaml_version Sys.word_size ;; -let geturl s = - let colonpos = try String.index s ':' with Not_found -> -1 in - let len = String.length s in - if colonpos >= 0 && colonpos + 3 < len - then ( - if s.[colonpos+1] = '/' && s.[colonpos+2] = '/' - then - let schemestartpos = - try String.rindex_from s colonpos ' ' - with Not_found -> -1 - in - let scheme = - String.sub s (schemestartpos+1) (colonpos-1-schemestartpos) - in - match scheme with - | "http" | "ftp" | "mailto" -> - let epos = - try String.index_from s colonpos ' ' - with Not_found -> len - in - String.sub s (schemestartpos+1) (epos-1-schemestartpos) - | _ -> E.s - else E.s - ) - else E.s -;; - let defconf = { scrollbw = 7 ; scrollh = 12 diff --git a/utils.ml b/utils.ml index b358436..5399a0c 100644 --- a/utils.ml +++ b/utils.ml @@ -274,3 +274,30 @@ let getcmdoutput errstr cmd = Ne.clo r @@ clofail "read end of the pipe"; s ;; + +let geturl s = + let colonpos = try String.index s ':' with Not_found -> -1 in + let len = String.length s in + if colonpos >= 0 && colonpos + 3 < len + then ( + if s.[colonpos+1] = '/' && s.[colonpos+2] = '/' + then + let schemestartpos = + try String.rindex_from s colonpos ' ' + with Not_found -> -1 + in + let scheme = + String.sub s (schemestartpos+1) (colonpos-1-schemestartpos) + in + match scheme with + | "http" | "https" | "ftp" | "mailto" -> + let epos = + try String.index_from s colonpos ' ' + with Not_found -> len + in + String.sub s (schemestartpos+1) (epos-1-schemestartpos) + | _ -> E.s + else E.s + ) + else E.s +;; -- 2.11.4.GIT