[wp-trac] [WordPress Trac] #26819: wp_make_link_relative() returns domain name instead of zero length string path when no path present
WordPress Trac
noreply at wordpress.org
Sun Jan 12 22:50:21 UTC 2014
#26819: wp_make_link_relative() returns domain name instead of zero length string
path when no path present
--------------------------+-----------------------------
Reporter: adiant | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Formatting | Version: 3.8
Severity: minor | Keywords:
--------------------------+-----------------------------
wp_make_link_relative() simply returns the URL passed to it when the URL
has no path, just a domain name. Instead, it should return a zero length
string.
A URL with a path of '/' correctly returns '/'.
Incorrect: var_dump( wp_make_link_relative( 'http://www.wordpress.org' )
) displays "string(24) "http://www.wordpress.org"
Correct: var_dump( wp_make_link_relative( 'http://www.wordpress.org/' ) )
displays string(1) "/"
Workaround: for my purposes, parse_url( $home_url, PHP_URL_PATH ) does
all that I need, but wp_make_link_relative() would still be useful when a
Query or Fragment is present in the URL.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/26819>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list