PluginProbe
Redirection / 5.3.3
Redirection v5.3.3
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 / url.php

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

58 lines 1.3 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 require_once __DIR__ . '/url-transform.php';
9 require_once __DIR__ . '/url-encode.php';
10
11 class Red_Url {
12 /**
13 * URL
14 *
15 * @var String
16 */
17 private $url;
18
19 /**
20 * Constructor
21 *
22 * @param string $url URL.
23 */
24 public function __construct( $url = '' ) {
25 $this->url = $url;
26 $this->url = str_replace( ' ', '%20', $this->url ); // deprecated
27 }
28
29 /**
30 * Get the raw URL
31 *
32 * @return string URL
33 */
34 public function get_url() {
35 return $this->url;
36 }
37
38 /**
39 * Match a target URL against the current URL, using any match flags
40 *
41 * @param string $requested_url Target URL.
42 * @param Red_Source_Flags $flags Match flags.
43 * @return boolean
44 */
45 public function is_match( $requested_url, Red_Source_Flags $flags ) {
46 if ( $flags->is_regex() ) {
47 $regex = new Red_Regex( $this->url, $flags->is_ignore_case() );
48
49 return $regex->is_match( $requested_url );
50 }
51
52 $path = new Red_Url_Path( $this->url );
53 $query = new Red_Url_Query( $this->url, $flags );
54
55 return $path->is_match( $requested_url, $flags ) && $query->is_match( $requested_url, $flags );
56 }
57 }
58