strip_query() static public method

Strips the query from the URL
static public strip_query ( string $url ) : string
$url string
return string
Beispiel #1
0
 function crawl()
 {
     $path = url::strip_query($this->raw);
     $path = (array) str::split($path, '/');
     if (a::first($path) == 'index.php') {
         array_shift($path);
     }
     // parse params
     foreach ($path as $p) {
         if (str::contains($p, ':')) {
             $parts = explode(':', $p);
             if (count($parts) < 2) {
                 continue;
             }
             $this->params->{$parts}[0] = $parts[1];
         } else {
             $this->path->_[] = $p;
         }
     }
     // get the extension from the last part of the path
     $this->extension = f::extension($this->path->last());
     if ($this->extension != false) {
         // remove the last part of the path
         $last = array_pop($this->path->_);
         $this->path->_[] = f::name($last);
     }
     return $this->path;
 }
Beispiel #2
0
 function path($key = null, $default = null)
 {
     $path = self::$path;
     if (!$path) {
         $path = url::strip_query(self::raw());
         $path = (array) str::split($path, '/');
         self::$path = $path;
     }
     if ($key === null) {
         return $path;
     }
     return a::get($path, $key, $default);
 }
Beispiel #3
0
 /**
  * Gets the extension of a file
  * 
  * @param  string  $file The filename or path
  * @return string 
  */
 static function extension($filename)
 {
     $ext = str_replace('.', '', strtolower(strrchr(trim($filename), '.')));
     $ext = url::strip_query($ext);
     $ext = preg_replace('!\\:.*!i', '', $ext);
     $ext = preg_replace('!\\#.*!i', '', $ext);
     return $ext;
 }
Beispiel #4
0
 function extension($filename)
 {
     $ext = str_replace('.', '', strtolower(strrchr(trim($filename), '.')));
     return url::strip_query($ext);
 }
Beispiel #5
0
 function map()
 {
     $url = url::strip_query(server::get('request_uri'));
     $url = str_replace(rtrim(c::get('router.root'), '/'), '', $url);
     $method = r::method();
     foreach (self::$routes as $key => $route) {
         if (!in_array($method, $route['methods'])) {
             continue;
         }
         $key = str_replace(')', ')?', $key);
         $args = array();
         $regex = preg_replace_callback('#@([\\w]+)(:([^/\\(\\)]*))?#', function ($matches) use(&$args) {
             $args[$matches[1]] = null;
             if (isset($matches[3])) {
                 return '(?P<' . $matches[1] . '>' . $matches[3] . ')';
             }
             return '(?P<' . $matches[1] . '>[^/\\?]+)';
         }, $key);
         if (preg_match('#^' . $regex . '(?:\\?.*)?$#i', $url, $matches)) {
             foreach ($args as $k => $v) {
                 self::$params[$k] = array_key_exists($k, $matches) ? urldecode($matches[$k]) : null;
             }
             return $route['callback'];
         }
     }
     return false;
 }
Beispiel #6
0
 /**
  * Extracts the filename from a file path
  * 
  * @param  string  $file The path
  * @return string 
  */
 static function filename($name)
 {
     $name = basename($name);
     $name = url::strip_query($name);
     $name = preg_replace('!\\:.*!i', '', $name);
     $name = preg_replace('!\\#.*!i', '', $name);
     return $name;
 }