Skip to content

Incorrect identification of the static part of the pattern for the disk root on Windows #63

@mrmlnc

Description

@mrmlnc

What were you expecting to happen?

expect(gp('C:/', { flipBackslashes: false })).toEqual('C:/');
expect(gp('C:/.', { flipBackslashes: false })).toEqual('C:/');
expect(gp('C:/*', { flipBackslashes: false })).toEqual('C:/');
expect(gp('C:/./*', { flipBackslashes: false })).toEqual('C:/.');
expect(gp('C://', { flipBackslashes: false })).toEqual('C:/');
expect(gp('C://*', { flipBackslashes: false })).toEqual('C:/');

What actually happened?

expect(gp('C:/', { flipBackslashes: false })).toEqual('C:'); // 🔴 C: instead of C:/
expect(gp('C:/.', { flipBackslashes: false })).toEqual('C:'); // 🔴 C: instead of C:/
expect(gp('C:/*', { flipBackslashes: false })).toEqual('C:'); // 🔴 C: instead of C:/
expect(gp('C:/./*', { flipBackslashes: false })).toEqual('C:/.'); // 🟢 
expect(gp('C://', { flipBackslashes: false })).toEqual('C:/'); // 🟢 
expect(gp('C://*', { flipBackslashes: false })).toEqual('C:/'); // 🟢 

Please give us a sample of your gulpfile

The examples above are tests for this repository.

Please provide the following information:

  • OS & version [e.g. MacOS Catalina 10.15.4]: Windows 11 PRO 22H2
  • node version (run node -v): v20.0.0
  • npm version (run npm -v): 9.6.4
  • gulp version (run gulp -v): nope

Additional information

The current result is not correct because its use leads to incorrect results in standard Node methods.like path.* or fs.*:

CWD: D:\\OpenSource\\glob-parent

const path = require('path');

path.win32.resolve('D:'); // CWD
path.win32.resolve('D:/'); // D:\\

const fs = require('fs');

fs.readdirSync('D:'); // list CWD
fs.readdirSync('D:/'); // list D:\\

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions