fixed the url parser so all urlhandlers have ^ tacked to the start
[glcas.git] / libglcas / urlparser.php
index 89c9bb1..d85692d 100644 (file)
@@ -23,10 +23,9 @@ class GLCASUrlParser {
                if(is_array($this->urlClasses)) {
                        foreach($this->urlClasses as $key => $val) {
                                error_log("checking url $url against $key, $val");
-                               if($url == "/") {
+                               if($key == "/") {
                                        $base = $val;
                                        error_log("base set to $val");
-                                       return new $val($this->config);
                                } 
                                
                                // TODO: this is quite messy really, need to think about how i do /'s in urls for url parsers
@@ -35,12 +34,18 @@ class GLCASUrlParser {
                                        error_log("catchall set to $val");
                                } else if($key != "/") {
                                        // now the rest
-                                       if(preg_match("/$key/", $url)) {
+                                       if(preg_match("/^$key/", $url)) {
                                                error_log("matched $url to $key and $val");
                                                return new $val($this->config);
                                        }
                                }
                        }
+                       
+                       // check for "bases"
+                       if($url == "/") {
+                               return new $base($this->config);
+                       }
+                       
                }
                error_log("get class returns default");
                return new $default($this->config);