diff --git a/src/assets/sitemapper.js b/src/assets/sitemapper.js index 1d51aa8..9b32939 100644 --- a/src/assets/sitemapper.js +++ b/src/assets/sitemapper.js @@ -323,7 +323,7 @@ export default class Sitemapper { return modified >= this.lastmod; }) .filter((site) => { - return this.isNotExcluded(site.loc[0]) + return !this.isExcluded(site.loc[0]) }) .map((site) => { if( !this.fields) { @@ -352,7 +352,7 @@ export default class Sitemapper { const sitemap = data.sitemapindex.sitemap .map((map) => map.loc && map.loc[0]) .filter((url) => { - return this.isNotExcluded(url) + return !this.isExcluded(url) }); // Parse all child urls within the concurrency limit in the settings @@ -456,14 +456,14 @@ export default class Sitemapper { } /** - * Checks if a site is not excluded based on the exclusion patterns. + * Checks if a urls is excluded based on the exclusion patterns. * * @param {string} url - The URL to check. - * @returns {boolean} Returns true if the urls is not excluded, false otherwise. + * @returns {boolean} Returns true if the urls is excluded, false otherwise. */ - isNotExcluded(url) { - if (this.exclusions.length === 0) return true; - return !this.exclusions.some((pattern) => pattern.test(url)); + isExcluded(url) { + if (this.exclusions.length === 0) return false; + return this.exclusions.some((pattern) => pattern.test(url)); } } diff --git a/src/tests/test.js b/src/tests/test.js index e456485..77f65c7 100644 --- a/src/tests/test.js +++ b/src/tests/test.js @@ -301,44 +301,44 @@ describe('Sitemapper', function () { }); }); - describe('isNotExcluded method', function () { - it('should return true when no exclusions are set', function () { - const result = sitemapper.isNotExcluded('https://foo.com/page1'); - result.should.be.true(); + describe('isExcluded method', function () { + it('should return false when no exclusions are set', function () { + const result = sitemapper.isExcluded('https://foo.com/page1'); + result.should.be.false(); }); - it('should return true when url does not match any exclusion patterns', function () { + it('should return false when url does not match any exclusion patterns', function () { sitemapper.exclusions = [/\.pdf$/, /private/]; - const result = sitemapper.isNotExcluded('https://foo.com/page1'); - result.should.be.true(); + const result = sitemapper.isExcluded('https://foo.com/page1'); + result.should.be.false(); }); it('should return false when url matches an exclusion pattern', function () { sitemapper.exclusions = [/\.pdf$/, /private/]; - const result = sitemapper.isNotExcluded('https://foo.com/document.pdf'); - result.should.be.false(); + const result = sitemapper.isExcluded('https://foo.com/document.pdf'); + result.should.be.true(); }); - it('should return false when url matches any of multiple exclusion patterns', function () { + it('should return true when url matches any of multiple exclusion patterns', function () { sitemapper.exclusions = [/\.pdf$/, /private/, /temp/]; - const result = sitemapper.isNotExcluded('https://foo.com/private/temp.html'); - result.should.be.false(); + const result = sitemapper.isExcluded('https://foo.com/private/temp.html'); + result.should.be.true(); }); it('should handle complex regex patterns correctly', function () { sitemapper.exclusions = [/^https:\/\/foo\.com\/([a-z]{2})\/private/] - const result1 = sitemapper.isNotExcluded('https://foo.com/en/private/page'); - const result2 = sitemapper.isNotExcluded('https://foo.com/en/public/page'); - result1.should.be.false(); - result2.should.be.true(); + const result1 = sitemapper.isExcluded('https://foo.com/en/private/page'); + const result2 = sitemapper.isExcluded('https://foo.com/en/public/page'); + result1.should.be.true(); + result2.should.be.false(); }); it('should handle case sensitivity correctly', function () { sitemapper.exclusions = [/private/i]; - const result1 = sitemapper.isNotExcluded('https://foo.com/PRIVATE/page'); - const result2 = sitemapper.isNotExcluded('https://foo.com/Private/page'); - result1.should.be.false(); - result2.should.be.false(); + const result1 = sitemapper.isExcluded('https://foo.com/PRIVATE/page'); + const result2 = sitemapper.isExcluded('https://foo.com/Private/page'); + result1.should.be.true(); + result2.should.be.true(); }); }); });