Skip to content

Commit 41ed624

Browse files
committed
fix: skip crawlable audit when running onSuccess against deploy url
1 parent b8f899e commit 41ed624

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

src/lib/get-settings/get-settings.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ describe('replacements', () => {
3434
expect(derivedSettings.settings.locale).toEqual('es');
3535
});
3636

37+
it('should add skipAudits if using a deployUrl', () => {
38+
const derivedSettings = getSettings({ preset: 'desktop' }, true);
39+
expect(derivedSettings.settings.skipAudits).toEqual(['seo/is-crawlable']);
40+
});
41+
3742
it('should error with incorrect syntax for process.env.SETTINGS', () => {
3843
process.env.SETTINGS = 'not json';
3944
expect(getSettings).toThrow(/Invalid JSON/);

src/lib/get-settings/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const mergeSettingsSources = (inputSettings = {}) => {
2020
return Object.assign({}, envSettings, inputSettings);
2121
};
2222

23-
const getSettings = (inputSettings) => {
23+
const getSettings = (inputSettings, isUsingDeployUrl) => {
2424
const settings = mergeSettingsSources(inputSettings);
2525
if (Object.keys(settings).length === 0) return;
2626

@@ -35,6 +35,12 @@ const getSettings = (inputSettings) => {
3535
derivedSettings.settings.locale = settings.locale;
3636
}
3737

38+
// If we are running against the Netlify deploy URL, the injected x-robots-tag will always cause the audit to fail,
39+
// likely producing a false positive, so we skip in this case
40+
if (isUsingDeployUrl) {
41+
derivedSettings.settings.skipAudits = ['seo/is-crawlable'];
42+
}
43+
3844
return derivedSettings;
3945
};
4046

src/lib/run-event/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const runEvent = async ({
4747
let errorMetadata = [];
4848

4949
try {
50-
const settings = getSettings(inputs?.settings);
50+
const settings = getSettings(inputs?.settings, isOnSuccess);
5151

5252
const allErrors = [];
5353
const data = [];

0 commit comments

Comments
 (0)