check-url ( href -- href' )


Vocabulary
farkup

Definition
USING: combinators kernel math namespaces sequences
urls.encoding ;

IN: farkup

: check-url ( href -- href' )
{
{ [ dup empty? ] [ drop invalid-url ] }
{ [ dup [ 127 > ] any? ] [ drop invalid-url ] }
{ [ dup first "/\\" member? ] [ drop invalid-url ] }
{
[ 58 over member? ]
[ dup absolute-url? [ drop invalid-url ] unless ]
}
[ relative-link-prefix get prepend "" like url-encode ]
} cond ;