PluginProbe
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution / 1.9.0
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution v1.9.0
2.0.1 trunk 1.0.0 1.1.0 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.5.0 1.6.0 1.6.1 1.7.0 1.7.1 1.8.0 1.9.0 2.0.0
solid-performance / src / Performance / Preload / Uri.php

Uri.php in Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution 1.9.0, at src/Performance/Preload/Uri.php

44 lines 961 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Transform URIs.
4 *
5 * @package SolidWP\Performance
6 */
7
8 declare( strict_types=1 );
9
10 namespace SolidWP\Performance\Preload;
11
12 use SolidWP\Performance\Symfony\Component\HttpClient\Exception\InvalidArgumentException;
13 use SolidWP\Performance\Symfony\Component\HttpClient\HttpClientTrait;
14
15 /**
16 * Transform URIs.
17 *
18 * @package SolidWP\Performance
19 */
20 final class Uri {
21
22 use HttpClientTrait;
23
24 /**
25 * Ensure we pass a relative URL to our Scoped HTTP client, which is configured
26 * to use the WP Home URL as the base_uri in order to prevent SSRF attacks.
27 *
28 * @param string $uri The URI that will be forced to a relative path.
29 *
30 * @throws InvalidArgumentException If the URL is malformed.
31 *
32 * @return string
33 */
34 public function make_relative( string $uri ): string {
35 $uri = self::parseUrl( $uri );
36 $uri['scheme'] = '';
37 $uri['authority'] = '';
38
39 $uri = implode( '', $uri );
40
41 return '/' . ltrim( $uri, '/\\' );
42 }
43 }
44