|
@@ 271-278 (lines=8) @@
|
| 268 |
|
/** |
| 269 |
|
* Tests whether a URL matches a specific regex. |
| 270 |
|
*/ |
| 271 |
|
public function test_validate_block_embed_regex() { |
| 272 |
|
$url = 'https://wordpress.com/tos/'; |
| 273 |
|
$allowed = array( '#^https?:\/\/(www.)?wordpress\.com(\/)?([^\/]+)?(\/)?$#' ); |
| 274 |
|
|
| 275 |
|
$validated_url = Jetpack_Gutenberg::validate_block_embed_url( $url, $allowed, true ); |
| 276 |
|
|
| 277 |
|
$this->assertEquals( $url, $validated_url ); |
| 278 |
|
} |
| 279 |
|
|
| 280 |
|
/** |
| 281 |
|
* Tests whether a URL does not match a specific regex. |
|
@@ 283-290 (lines=8) @@
|
| 280 |
|
/** |
| 281 |
|
* Tests whether a URL does not match a specific regex. |
| 282 |
|
*/ |
| 283 |
|
public function test_validate_block_embed_regex_mismatch() { |
| 284 |
|
$url = 'https://www.facebook.com/WordPresscom/'; |
| 285 |
|
$allowed = array( '#^https?:\/\/(www.)?wordpress\.com(\/)?([^\/]+)?(\/)?$#' ); |
| 286 |
|
|
| 287 |
|
$validated_url = Jetpack_Gutenberg::validate_block_embed_url( $url, $allowed, true ); |
| 288 |
|
|
| 289 |
|
$this->assertFalse( $validated_url ); |
| 290 |
|
} |
| 291 |
|
} |
| 292 |
|
|