]> gitweb.factorcode.org Git - factor.git/commitdiff
Auto load urls.secure when needed
authorSankaranarayanan Viswanathan <rationalrevolt@gmail.com>
Thu, 29 Oct 2015 01:13:51 +0000 (21:13 -0400)
committerJohn Benediktsson <mrjbq7@gmail.com>
Fri, 30 Oct 2015 04:28:22 +0000 (21:28 -0700)
basis/urls/urls.factor
core/vocabs/vocabs.factor

index bc99601f761c85cf690e7deb05c020b01017e955..3c38961bc415095a593dec8d2115f38413980463 100644 (file)
@@ -4,7 +4,7 @@
 USING: accessors arrays assocs combinators fry hashtables
 io.pathnames io.sockets kernel lexer make math.parser
 namespaces peg.ebnf present sequences splitting strings
-strings.parser urls.encoding vocabs.loader ;
+strings.parser urls.encoding vocabs vocabs.loader ;
 
 IN: urls
 
@@ -187,7 +187,7 @@ PRIVATE>
         [ protocol>> protocol-port ]
         tri or <inet>
     ] [ protocol>> ] bi
-    secure-protocol? [ >secure-addr ] when ;
+    secure-protocol? [ "urls.secure" ensure-vocab-loaded >secure-addr ] when ;
 
 : set-url-addr ( url addr -- url )
     [ host>> >>host ] [ port>> >>port ] bi ;
index 66f706eac72c9489b9f83549eb822f53f30c2b36..21fab738f59ede6860f339e9ff5d300b031ee60e 100644 (file)
@@ -161,3 +161,6 @@ M: string require ( vocab -- )
 
 : load-vocab ( name -- vocab )
     [ require ] [ lookup-vocab ] bi ;
+
+: ensure-vocab-loaded ( name -- )
+    dup lookup-vocab [ drop ] [ require ] if ;