Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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] || {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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;
Expand Down
Loading