PluginProbe
Redirection / 4.4.2
Redirection v4.4.2
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-match.php

url-match.php in Redirection 4.4.2, at models/url-match.php

51 lines 917 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class Red_Url_Match {
4 private $url;
5
6 public function __construct( $url ) {
7 $this->url = $url;
8 }
9
10 /**
11 * Get the plain 'matched' URL:
12 *
13 * - Lowercase
14 * - No trailing slashes
15 *
16 * @return string URL
17 */
18 public function get_url() {
19 // Remove query params, and decode any encoded characters
20 $url = new Red_Url_Path( $this->url );
21 $path = $url->get_without_trailing_slash();
22
23 // URL encode
24 $decode = [
25 '/',
26 ':',
27 '[',
28 ']',
29 '@',
30 '~',
31 ',',
32 '(',
33 ')',
34 ';',
35 ];
36
37 // URL encode everything - this converts any i10n to the proper encoding
38 $path = rawurlencode( $path );
39
40 // We also converted things we dont want encoding, such as a /. Change these back
41 foreach ( $decode as $char ) {
42 $path = str_replace( rawurlencode( $char ), $char, $path );
43 }
44
45 // Lowercase everything
46 $path = Red_Url_Path::to_lower( $path );
47
48 return $path ? $path : '/';
49 }
50 }
51