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.

Built from https://develop.svn.wordpress.org/trunk@26972


git-svn-id: http://core.svn.wordpress.org/trunk@26851 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2014-01-17 07:47:10 +00:00
parent 8adc7db517
commit d9b0e70d4a
1 changed files with 5 additions and 3 deletions

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;
}