! Copyright (C) 2008, 2009 Doug Coleman, Daniel Ehrenberg.
! See http://factorcode.org/license.txt for BSD license.
-USING: sequences kernel splitting lists fry accessors assocs math.order
-math combinators namespaces urls.encoding xml.syntax xmode.code2html
-xml.data arrays strings vectors xml.writer io.streams.string locals
-unicode ;
+USING: accessors arrays assocs combinators fry io.streams.string
+kernel lists locals math math.order namespaces sequences splitting
+strings urls urls.encoding xml.data xml.syntax xml.writer
+xmode.code2html ;
IN: farkup
SYMBOL: relative-link-prefix
TUPLE: line-break ;
: absolute-url? ( string -- ? )
- { "http://" "https://" "ftp://" } [ head? ] with any? ;
+ >url protocol>> >boolean ;
: simple-link-title ( string -- string' )
dup absolute-url? [ "/" split1-last swap or ] unless ;
{ t } [ "http://reddit.com" url-string? ] unit-test
{ t } [ "https://reddit.com" url-string? ] unit-test
-{ f } [ "ftp://reddit.com" url-string? ] unit-test
+{ t } [ "ftp://reddit.com" url-string? ] unit-test
+{ f } [ "moo" url-string? ] unit-test
{ f } [ 123 url-string? ] unit-test
! Copyright (C) 2011 John Benediktsson
! See http://factorcode.org/license.txt for BSD license
-USING: accessors combinators.short-circuit io.pathnames
-sequences strings system ui.operations urls vocabs ;
+USING: accessors io.pathnames kernel sequences strings system
+ui.operations urls vocabs ;
IN: webbrowser
[ url? ] \ open-url H{ } define-operation
-PREDICATE: url-string < string
- { [ "http://" head? ] [ "https://" head? ] } 1|| ;
+PREDICATE: url-string < string >url protocol>> >boolean ;
[ url-string? ] \ open-url H{ } define-operation