]> gitweb.factorcode.org Git - factor.git/commitdiff
webbrowser: support open-url on "url-like" strings.
authorJohn Benediktsson <mrjbq7@gmail.com>
Sat, 22 Sep 2012 23:49:53 +0000 (16:49 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Sat, 22 Sep 2012 23:49:53 +0000 (16:49 -0700)
basis/webbrowser/webbrowser.factor

index ba586e4fe806f5ddf162cadb982e222605f6b199..1f76f2e2245384bc1c90885fa2cca6ca828bce2b 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2011 John Benediktsson
 ! See http://factorcode.org/license.txt for BSD license
 
-USING: combinators present system ui.operations urls vocabs ;
+USING: combinators combinators.short-circuit present sequences strings system
+ui.operations urls vocabs ;
 
 IN: webbrowser
 
@@ -17,3 +18,8 @@ HOOK: open-file os ( path -- )
     >url present open-file ;
 
 [ url? ] \ open-url H{ } define-operation
+
+PREDICATE: url-like < string
+    { [ "http://" head? ] [ "https://" head? ] } 1|| ;
+
+[ url-like? ] \ open-url H{ } define-operation