exploration
exploration copied to clipboard
Bug: Handle Both Windows and UNIX Path Separators
Description:
The current SEP_NEGATE_RE regular expression only supports UNIX-style paths with the / separator. However, it fails to handle Windows-style paths, which use the \ separator. This bug causes the split function to incorrectly split Windows paths.
Steps to Reproduce:
- Run the
splitfunction with a Windows path, for example:split("C:\\Users\\Administrator\\Documents\\KKNote\\Notes.md"); - The function does not properly split the path and returns incorrect results.
Expected Behavior:
The split function should correctly handle both UNIX-style and Windows-style paths. It should split the path by both / and \ separators, and return the correct path components.
Solution:
- Modify the
SEP_NEGATE_REregular expression to handle both/and\as valid path separators:const SEP_NEGATE_RE = /[^\\/]+/g; - This change will allow the function to split paths with either separator.
Example:
For the input path C:\\Users\\Administrator\\Documents\\KKNote\\Notes.md, the expected output should be:
[
"C:",
"Users",
"Administrator",
"Documents",
"KKNote",
"Notes.md"
]
Would accept a PR for this!