8000 fix(Issue-996): replace whitespaces in namespaces string with commas globally by pdahal-cx · Pull Request #997 · debug-js/debug · GitHub
[go: up one dir, main page]

Skip to content

fix(Issue-996): replace whitespaces in namespaces string with commas globally #997

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

Merged
merged 1 commit into from
Mar 21, 2025

Conversation

pdahal-cx
Copy link
Contributor

This change uses a regex to replace whitespaces in namespaces string with commas globally instead of just the first space occurrence. This fixes the issue reported below.

Issue: #996
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- Qix- merged commit a0497bd into debug-js:master Mar 21, 2025
@Qix-
Copy link
Member
Qix- commented Mar 21, 2025

Thanks! I can't do a release today but if I miss it over the next week just ping me again and I'll push one out. Appreciate the quick turnaround :)

@gregmartyn
Copy link

@Qix- ping in case you forgot about doing the release

@Qix-
Copy link
Member
Qix- commented May 13, 2025

@gregmartyn Thanks! Published as 4.4.1.

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

Successfully merging this pull request may close these issues.

3 participants
0