Unit tests for get_url_in_content(). Return false when no content is passed, to match the return value of no links being found.

props mdbitz.
#26171.


git-svn-id: https://develop.svn.wordpress.org/trunk@26972 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin
2014-01-17 07:46:33 +00:00
parent 238f9d2b0a
commit 9f5c78b676
2 changed files with 54 additions and 3 deletions
+5 -3
View File
@@ -3770,11 +3770,13 @@ function wp_unslash( $value ) {
* @return string The found URL.
*/
function get_url_in_content( $content ) {
if ( empty( $content ) )
return '';
if ( empty( $content ) ) {
return false;
}
if ( preg_match( '/<a\s[^>]*?href=([\'"])(.+?)\1/is', $content, $matches ) )
if ( preg_match( '/<a\s[^>]*?href=([\'"])(.+?)\1/is', $content, $matches ) ) {
return esc_url_raw( $matches[2] );
}
return false;
}