diff --git a/packages/spacecat-shared-data-access/src/models/site/config.js b/packages/spacecat-shared-data-access/src/models/site/config.js index d56f4d1f2..2df515796 100644 --- a/packages/spacecat-shared-data-access/src/models/site/config.js +++ b/packages/spacecat-shared-data-access/src/models/site/config.js @@ -495,6 +495,7 @@ export const configSchema = Joi.object({ mentions: Joi.object().pattern(Joi.string(), Joi.array().items(Joi.string())), excludedURLs: Joi.array().items(Joi.string()), autofixExcludedURLs: Joi.array().items(Joi.string()), + excludedPathPrefixes: Joi.array().items(Joi.string()), manualOverwrites: Joi.array().items(Joi.object({ brokenTargetURL: Joi.string().optional(), targetURL: Joi.string().optional(), @@ -577,6 +578,7 @@ export const Config = (data = {}) => { self.getImports = () => state.imports; self.getExcludedURLs = (type) => state?.handlers?.[type]?.excludedURLs; self.getAutofixExcludedURLs = (type) => state?.handlers?.[type]?.autofixExcludedURLs; + self.getExcludedPathPrefixes = (type) => state?.handlers?.[type]?.excludedPathPrefixes; self.getManualOverwrites = (type) => state?.handlers?.[type]?.manualOverwrites; self.getFixedURLs = (type) => state?.handlers?.[type]?.fixedURLs; self.getIncludedURLs = (type) => state?.handlers?.[type]?.includedURLs; @@ -882,6 +884,12 @@ export const Config = (data = {}) => { state.handlers[type].autofixExcludedURLs = autofixExcludedURLs; }; + self.updateExcludedPathPrefixes = (type, excludedPathPrefixes) => { + state.handlers = state.handlers || {}; + state.handlers[type] = state.handlers[type] || {}; + state.handlers[type].excludedPathPrefixes = excludedPathPrefixes; + }; + self.updateManualOverwrites = (type, manualOverwrites) => { state.handlers = state.handlers || {}; state.handlers[type] = state.handlers[type] || {}; diff --git a/packages/spacecat-shared-data-access/test/unit/models/site/config.test.js b/packages/spacecat-shared-data-access/test/unit/models/site/config.test.js index cd09a311e..413a2266d 100644 --- a/packages/spacecat-shared-data-access/test/unit/models/site/config.test.js +++ b/packages/spacecat-shared-data-access/test/unit/models/site/config.test.js @@ -413,6 +413,19 @@ describe('Config Tests', () => { expect(config.getAutofixExcludedURLs('non-existent-handler')).to.be.undefined; }); + it('correctly updates the excluded path prefixes', () => { + const config = Config(); + config.updateExcludedPathPrefixes('prerender', ['/jp/ja', '/de/de']); + + const excludedPathPrefixes = config.getExcludedPathPrefixes('prerender'); + expect(excludedPathPrefixes).to.deep.equal(['/jp/ja', '/de/de']); + }); + + it('returns undefined for excluded path prefixes when handler is not present', () => { + const config = Config(); + expect(config.getExcludedPathPrefixes('non-existent-handler')).to.be.undefined; + }); + it('correctly updates the manual overrides', () => { const config = Config(); const manualOverwrites = [ @@ -476,6 +489,7 @@ describe('Config Tests', () => { expect(config.getHandlerConfig('404')).to.be.undefined; expect(config.getExcludedURLs('404')).to.be.undefined; expect(config.getAutofixExcludedURLs('404')).to.be.undefined; + expect(config.getExcludedPathPrefixes('404')).to.be.undefined; expect(config.getManualOverwrites('404')).to.be.undefined; expect(config.getFixedURLs('404')).to.be.undefined; expect(config.getIncludedURLs('404')).to.be.undefined;