Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/pluginutils/src/createFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,12 @@ const createFilter: CreateFilter = function createFilter(include?, exclude?, opt
const includeMatchers = ensureArray(include).map(getMatcher);
const excludeMatchers = ensureArray(exclude).map(getMatcher);

if (!includeMatchers.length && !excludeMatchers.length)
return (id) => typeof id === 'string' && !id.includes('\0');

return function result(id: string | unknown): boolean {
if (typeof id !== 'string') return false;
if (/\0/.test(id)) return false;
if (id.includes('\0')) return false;

const pathId = normalizePath(id);

Expand Down
4 changes: 3 additions & 1 deletion packages/pluginutils/src/normalizePath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import { win32, posix } from 'path';

import type { NormalizePath } from '../types';

const normalizePathRegExp = new RegExp(`\\${win32.sep}`, 'g');

const normalizePath: NormalizePath = function normalizePath(filename: string) {
return filename.split(win32.sep).join(posix.sep);
return filename.replace(normalizePathRegExp, posix.sep);
};

export { normalizePath as default };
Loading