PluginProbe
Redirection / 5.0
Redirection v5.0
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.0, at models/url/url.php

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