]> gitweb.factorcode.org Git - factor.git/commitdiff
Revert "urls: Allow URLs of the form //foo.com, which take on the protocol of the...
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 12 Mar 2014 03:20:23 +0000 (20:20 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 12 Mar 2014 03:20:23 +0000 (20:20 -0700)
This reverts commit e6598fc22fd91309288fbe9840f7872d8fd84438.

basis/urls/urls-tests.factor
basis/urls/urls.factor

index e196161e9b2dad82119f115c1d4423c18d55b62d..e188a1c64572466cba6e51f7a0fc62d618210d4d 100644 (file)
@@ -225,13 +225,6 @@ urls [
     derive-url
 ] unit-test
 
-! Support //foo.com, which has the same protocol as the url we derive from
-[ URL" http://foo.com" ]
-[ URL" http://google.com" URL" //foo.com" derive-url ] unit-test
-
-[ URL" https://foo.com" ]
-[ URL" https://google.com" URL" //foo.com" derive-url ] unit-test
-
 [ "a" ] [
     <url> "a" "b" set-query-param "b" query-param
 ] unit-test
@@ -264,4 +257,4 @@ urls [
 
 [ "/" ] [ "http://www.jedit.org" >url path>> ] unit-test
 
-[ "USING: urls ;\nURL\" foo\"" ] [ URL" foo" unparse-use ] unit-test
+[ "USING: urls ;\nURL\" foo\"" ] [ URL" foo" unparse-use ] unit-test
\ No newline at end of file
index 2e1f98080662dab2e3329e0f26c063db928fdd2e..66e6ee01eb4ec703af0619412d3363aa431fa126 100644 (file)
@@ -57,8 +57,7 @@ hostname-spec = hostname ("/"|!(.)) => [[ first ]]
 auth     = (username (":" password  => [[ second ]])? "@"
                                     => [[ first2 2array ]])?
 
-url      = (((protocol "://") => [[ first ]] auth hostname)
-                    | (("//") => [[ f ]] auth hostname))?
+url      = ((protocol "://")        => [[ first ]] auth hostname)?
            (pathname)?
            ("?" query               => [[ second ]])?
            ("#" anchor              => [[ second ]])?
@@ -107,7 +106,9 @@ M: pathname >url string>> >url ;
     [ port>> ] [ port>> ] [ protocol>> protocol-port ] tri =
     [ drop f ] when ;
 
-: unparse-host-part ( url -- )
+: unparse-host-part ( url protocol -- )
+    %
+    "://" %
     {
         [ unparse-username-password ]
         [ host>> url-encode % ]
@@ -115,22 +116,10 @@ M: pathname >url string>> >url ;
         [ path>> "/" head? [ "/" % ] unless ]
     } cleave ;
 
-! URL" //foo.com" takes on the protocol of the url it's derived from
-: unparse-protocol ( url -- )
-    dup protocol>> [
-        % "://" % unparse-host-part
-    ] [
-        dup host>> [
-            "//" % unparse-host-part
-        ] [
-            drop
-        ] if
-    ] if* ;
-
 M: url present
     [
         {
-            [ unparse-protocol ]
+            [ dup protocol>> dup [ unparse-host-part ] [ 2drop ] if ]
             [ path>> url-encode % ]
             [ query>> dup assoc-empty? [ drop ] [ "?" % assoc>query % ] if ]
             [ anchor>> [ "#" % present url-encode % ] when* ]