[wp-trac] [WordPress Trac] #22267: Add optional boolean argument to trailingslashit() and untrailingslashit()
WordPress Trac
noreply at wordpress.org
Wed Oct 24 05:01:36 UTC 2012
#22267: Add optional boolean argument to trailingslashit() and untrailingslashit()
-------------------------+------------------------------
Reporter: knutsp | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Filesystem | Version: 2.2
Severity: normal | Resolution:
Keywords: 2nd-opinion |
-------------------------+------------------------------
Comment (by knutsp):
> I think we could potentially also make the assumption that
untrailingslashit() should always remove trailing / and \ from the given
string instead of adding complexity to it.
Yes, that was my first thought, but I didn't have the guts to propose a
change to the default behaviour of a function introduced many years ago,
when it's actually not broken. untrailingslashit($str) removes trailing
slashes from $str and that's it. Count on it to do just that. And
tralingslashit() depends on it, so likewise.
The functions may be used in plugins and themes for things that wasn't
expected at the time it was introduced. The added complexity is just
extending it a bit. Fine to have some (predictable and well-thought)
complexity in a helper function to avoid complexity in code in general.
> I'd rather we didn't use DIRECTORY_SEPARATOR at all and standardised on
/ like we already have.
The alternative is to use both '/' and '\' for ''removal'' in
untrailingslashit(), safely assuming that there are only two possible
separators.
For ''adding'' a separator in trailingslashit(), in case of $is_path is
given and true, it's fine with me to standardize on '/'. My suggestion
has, as I mentioned, just to do with a reasonably expected behaviour on
Windows after introducing an optional argument.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/22267#comment:3>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list