Strip multiple slashes in CoreLibs Convert Strings

This commit is contained in:
Clemens Schwaighofer
2024-02-14 12:26:17 +09:00
parent ec9275d8d3
commit a377ab4b61
2 changed files with 90 additions and 0 deletions

View File

@@ -118,6 +118,22 @@ class Strings
return $value;
}
}
/**
* Strip any duplicated slahes from a path
* eg: //foo///bar/foo.inc -> /foo/bar/foo.inc
*
* @param string $path Path to strip slashes from
* @return string Clean path
*/
public static function stripMultiplePathSlashes(string $path): string
{
return preg_replace(
'#/+#',
'/',
$path
);
}
}
// __END__