PluginProbe
Redirection / 4.8
Redirection v4.8
5.10.0 5.9.0 5.8.1 5.8.0 3.7.2 3.7.3 4.0 4.0.1 4.1 4.1.1 4.2 4.2.1 4.2.2 4.2.3 4.3 4.3.1 4.3.2 4.3.3 4.4 4.4.1 4.4.2 4.5 4.5.1 4.6.2 4.7.1 All 130 releases
redirection / models / url.php

url.php in Redirection 4.8, at models/url.php

46 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 require_once __DIR__ . '/url-query.php';
4 require_once __DIR__ . '/url-path.php';
5 require_once __DIR__ . '/url-match.php';
6 require_once __DIR__ . '/url-flags.php';
7 require_once __DIR__ . '/url-request.php';
8
9 class Red_Url {
10 private $url;
11
12 public function __construct( $url = '' ) {
13 $this->url = $url;
14 $this->url = str_replace( ' ', '%20', $this->url ); // deprecated
15 }
16
17 /**
18 * Get the raw URL
19 *
20 * @return string URL
21 */
22 public function get_url() {
23 return $this->url;
24 }
25
26 /**
27 * Match a target URL against the current URL, using any match flags
28 *
29 * @param string $requested_url Target URL
30 * @param Red_Source_Flags $flags Match flags
31 * @return boolean
32 */
33 public function is_match( $requested_url, Red_Source_Flags $flags ) {
34 if ( $flags->is_regex() ) {
35 $regex = new Red_Regex( $this->url, $flags->is_ignore_case() );
36
37 return $regex->is_match( $requested_url );
38 }
39
40 $path = new Red_Url_Path( $this->url );
41 $query = new Red_Url_Query( $this->url, $flags );
42
43 return $path->is_match( $requested_url, $flags ) && $query->is_match( $requested_url, $flags );
44 }
45 }
46