Skip to content

namespaces string is incorrectly split for space delimited strings #996

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pdahal-cx opened this issue Mar 20, 2025 · 1 comment
Closed

Comments

@pdahal-cx
Copy link
Contributor

In the following code in src/common.js, the namespaces string with multiple space delimiters is incorrectly only split at the occurrence of first space due to the replace() function only replacing the first occurrence of space with a comma. This leads to a names array of only two string elements with the second element possibly being incorrect. The replace() function should replace spaces with commas globally.

const split = (typeof namespaces === 'string' ? namespaces : '')
			.trim()
			.replace(' ', ',')
			.split(',')
			.filter(Boolean);

		for (const ns of split) {
			if (ns[0] === '-') {
				createDebug.skips.push(ns.slice(1));
			} else {
				createDebug.names.push(ns);
			}
		}
@Qix-
Copy link
Member

Qix- commented Mar 21, 2025

Good catch, PR welcome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants