| @@ -3,8 +3,9 @@ | ||
| 3 | 3 | namespace Yoast\WP\SEO\Routes; |
| 4 | 4 | |
| 5 | 5 | use WP_REST_Request; |
| 6 | 6 | use WP_REST_Response; |
| 7 | +use WPSEO_Utils; | |
| 7 | 8 | use Yoast\WP\SEO\Actions\Indexables\Indexable_Head_Action; |
| 8 | 9 | use Yoast\WP\SEO\Conditionals\Headless_Rest_Endpoints_Enabled_Conditional; |
| 9 | 10 | use Yoast\WP\SEO\Main; |
| 10 | 11 | |
| @@ -17,9 +18,9 @@ | ||
| 17 | 18 | * The posts route constant. |
| 18 | 19 | * |
| 19 | 20 | * @var string |
| 20 | 21 | */ |
| 21 | - const HEAD_FOR_URL_ROUTE = 'get_head'; | |
| 22 | + public const HEAD_FOR_URL_ROUTE = 'get_head'; | |
| 22 | 23 | |
| 23 | 24 | /** |
| 24 | 25 | * The full posts route constant. |
| 25 | 26 | * |
| @@ -24,9 +25,9 @@ | ||
| 24 | 25 | * The full posts route constant. |
| 25 | 26 | * |
| 26 | 27 | * @var string |
| 27 | 28 | */ |
| 28 | - const FULL_HEAD_FOR_URL_ROUTE = Main::API_V1_NAMESPACE . '/' . self::HEAD_FOR_URL_ROUTE; | |
| 29 | + public const FULL_HEAD_FOR_URL_ROUTE = Main::API_V1_NAMESPACE . '/' . self::HEAD_FOR_URL_ROUTE; | |
| 29 | 30 | |
| 30 | 31 | /** |
| 31 | 32 | * The head action. |
| 32 | 33 | * |
| @@ -45,9 +46,9 @@ | ||
| 45 | 46 | |
| 46 | 47 | /** |
| 47 | 48 | * Returns the conditionals based in which this loadable should be active. |
| 48 | 49 | * |
| 49 | - * @return array | |
| 50 | + * @return array<string> | |
| 50 | 51 | */ |
| 51 | 52 | public static function get_conditionals() { |
| 52 | 53 | return [ Headless_Rest_Endpoints_Enabled_Conditional::class ]; |
| 53 | 54 | } |
| @@ -93,9 +94,10 @@ | ||
| 93 | 94 | * |
| 94 | 95 | * @return bool Whether or not the url is valid. |
| 95 | 96 | */ |
| 96 | 97 | public function is_valid_url( $url ) { |
| 97 | - if ( \filter_var( \utf8_uri_encode( $url ), \FILTER_VALIDATE_URL ) === false ) { | |
| 98 | + $url = WPSEO_Utils::sanitize_url( \utf8_uri_encode( $url ) ); | |
| 99 | + if ( \filter_var( $url, \FILTER_VALIDATE_URL ) === false ) { | |
| 98 | 100 | return false; |
| 99 | 101 | } |
| 100 | 102 | return true; |
| 101 | 103 | } |