Add backslash to the regex for matching Windows paths correctly#39
Add backslash to the regex for matching Windows paths correctly#39gitlost merged 2 commits intowp-cli:masterfrom
Conversation
|
Thanks for the PR @ericgopak . I think though a better way to fix the issue would be to normalize the directory separators first in There should be a /**
* Normalizes directory separators to slashes.
*
* @param string $path Path to convert.
*
* @return string Path with all backslashes replaced by slashes.
*/
public static function normalize_directory_separators( $path ) {
return str_replace( '\\', '/', $path );
}and then call it in $pathname = self::normalize_directory_separators( substr( $file_info->getPathname(), strlen( $path ) ) ); |
|
Thanks a lot for the review @gitlost ! You are totally right, I haven't noticed that Apparently my previous solution didn't work at all, although it did get rid of error messages :/ |
|
I agree that the normalization function should be moved up to |
|
Thanks very much @ericgopak for the superquick response and feedback!
Yes, you're right, they should be.
Yes, this should be addressed in the framework If you have the time and you'd like to submit a PR to add the normalization function to |
|
Thanks @gitlost ! Should we create a new issue for that? I am new to WP-CLI repo and to contributing to WP in general, so any guidance is greatly appreciated :) For example, how should I move the normalization function up to |
|
Good stuff!
A straight PR referencing this PR will suffice in this case.
For the moment just do the PR on Ta! |
Fixing issue #35 - adding backslash to the regex for matching Windows paths correctly
This solves the issue on Windows.
It's funny how backslash should be escaped, but here's a reference why that's so: https://www.developwebsites.net/match-backslash-preg_match-php/