PluginProbe
Redirection / 4.0
Redirection v4.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.php

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

45 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 include_once dirname( __FILE__ ) . '/url-query.php';
4 include_once dirname( __FILE__ ) . '/url-path.php';
5 include_once dirname( __FILE__ ) . '/url-match.php';
6 include_once dirname( __FILE__ ) . '/url-flags.php';
7
8 class Red_Url {
9 private $url;
10
11 public function __construct( $url = '' ) {
12 $this->url = $url;
13 $this->url = str_replace( ' ', '%20', $this->url ); // deprecated
14 }
15
16 /**
17 * Get the raw URL
18 *
19 * @return string URL
20 */
21 public function get_url() {
22 return $this->url;
23 }
24
25 /**
26 * Match a target URL against the current URL, using any match flags
27 *
28 * @param string $requested_url Target URL
29 * @param Red_Source_Flags $flags Match flags
30 * @return boolean
31 */
32 public function is_match( $requested_url, Red_Source_Flags $flags ) {
33 if ( $flags->is_regex() ) {
34 $regex = new Red_Regex( $this->url, $flags->is_ignore_case() );
35
36 return $regex->is_match( $requested_url );
37 }
38
39 $path = new Red_Url_Path( $this->url );
40 $query = new Red_Url_Query( $this->url );
41
42 return $path->is_match( $requested_url, $flags ) && $query->is_match( $requested_url, $flags );
43 }
44 }
45