mirror of
https://github.com/archtechx/tenancy.git
synced 2026-09-20 16:44:04 +00:00
improve wording in comments
This commit is contained in:
parent
ca9afad3a5
commit
7659754629
1 changed files with 5 additions and 4 deletions
|
|
@ -258,18 +258,19 @@ class FilesystemTenancyBootstrapper implements TenancyBootstrapper
|
||||||
* Normalize the path to use the separator of the current OS.
|
* Normalize the path to use the separator of the current OS.
|
||||||
*
|
*
|
||||||
* The separators are also deduplicated, with two exceptions:
|
* The separators are also deduplicated, with two exceptions:
|
||||||
* - if the path begins with \\ on Windows (i.e. a UNC path), the *leading* separators won't end up deduplicated
|
* - if the path begins with \\ on Windows (i.e. a UNC path), the *leading* separators won't be deduplicated
|
||||||
* - if the path contains non-UTF-8 characters, the separators won't be deduplicated at all (since str()->deduplicate() only works on UTF-8 strings).
|
* - if the path contains non-UTF-8 characters, the separators won't be deduplicated since str()->deduplicate() only supports UTF-8 strings)
|
||||||
*/
|
*/
|
||||||
protected function normalizePath(string $path): string
|
protected function normalizePath(string $path): string
|
||||||
{
|
{
|
||||||
$path = str_replace('/', DIRECTORY_SEPARATOR, $path);
|
$path = str_replace('/', DIRECTORY_SEPARATOR, $path);
|
||||||
|
|
||||||
// On Windows, a path starting with two separators is a UNC path (e.g. '\\server\share'),
|
// On Windows, a path starting with two separators is a UNC path (e.g. '\\server\share'),
|
||||||
// so the leading separator that got collapsed by deduplicate() should be added back.
|
// so the leading separator that got collapsed by deduplicate() should be added back (only one \ will be kept, so we use one for the prefix).
|
||||||
$uncPrefix = DIRECTORY_SEPARATOR === '\\' && str_starts_with($path, '\\\\') ? DIRECTORY_SEPARATOR : '';
|
$uncPrefix = DIRECTORY_SEPARATOR === '\\' && str_starts_with($path, '\\\\') ? DIRECTORY_SEPARATOR : '';
|
||||||
|
|
||||||
// Since deduplicate() only supports UTF-8 paths, paths with non-UTF-8 characters will keep the duplicate separators.
|
// Since deduplicate() only supports UTF-8 paths, paths with non-UTF-8 characters will not
|
||||||
|
// be deduplicated since deduplicate() returns an empty result with unsupported strings
|
||||||
$path = str($path)->deduplicate(DIRECTORY_SEPARATOR)->toString() ?: $path;
|
$path = str($path)->deduplicate(DIRECTORY_SEPARATOR)->toString() ?: $path;
|
||||||
|
|
||||||
return $uncPrefix . rtrim($path, DIRECTORY_SEPARATOR);
|
return $uncPrefix . rtrim($path, DIRECTORY_SEPARATOR);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue