Fix only replacing wildcard at end in `toNamespace`
The docs state that, when running debug.disable(), it will return the namespaces currently enabled and skipped. They are, however, often malformed. This seems to be because the toNamespace method only replaces a trailing *.
debug.enable('api:*,-*:verbose,-api:*:verbose');
const prevConfig = debug.disable();
console.log(prevConfig); // -> api:*,-.*?:verbose,-api:.*?:verbose
console.log(prevConfig); should have returned api:*,-*:verbose,-api:*:verbose.
The issue seems to be fixed by removing the $ in the replace regexp in toNamespace.
It might be nice to improve the following test too:
describe('rebuild namespaces string (disable)', () => {
it('handle names, skips, and wildcards', () => {
debug.enable('test,abc*,-abc');
const namespaces = debug.disable();
assert.deepStrictEqual(namespaces, 'test,abc*,-abc');
// ^ could use more tests, maybe: *,test,-test,abc*,*abc,abc:*:xyz,-abc:*:xyz,-*:verbose (etcetera)
});
// ...
});
However, for the sake of keeping this PR clean, I haven't added that to this PR.
Coverage remained the same at 87.692% when pulling 9f5ed0369e230008fba21b282ad55545ab230576 on Anoesj:fix/wildcard-replace into 22e13fe07e21f32888201aa40833599fd10a4fbb on visionmedia:master.
Coverage remained the same at 87.692% when pulling 9f5ed0369e230008fba21b282ad55545ab230576 on Anoesj:fix/wildcard-replace into 22e13fe07e21f32888201aa40833599fd10a4fbb on visionmedia:master.
I wonder how to get the maintainer's attention to get contribution merged in?
I'm always looking, the project is currently blocked due to Node feature parity issues when moving from CJS to ESM. Please see the roadmap pinned on the repo.
Further, .enable() and .disable() have a ton of issues as it stands and need to be rethought/reworked entirely.