diff --git a/cypress/integration/main-page.spec.js b/cypress/integration/main-page.spec.js index 874d056adba42..9e38bb34868d3 100644 --- a/cypress/integration/main-page.spec.js +++ b/cypress/integration/main-page.spec.js @@ -62,4 +62,13 @@ describe('Main page', function () { cy.get(`img[src='${backendUrl}/github/issues/badges/shields?color=orange']`) }) + + it('Do not duplicate example parameters', function () { + cy.visit('/category/social') + + cy.contains('GitHub Sponsors').click() + cy.get('[name="style"]').should($style => { + expect($style).to.have.length(1) + }) + }) }) diff --git a/frontend/components/customizer/query-string-builder.tsx b/frontend/components/customizer/query-string-builder.tsx index cde85ae7bce98..4b8ff970ec79e 100644 --- a/frontend/components/customizer/query-string-builder.tsx +++ b/frontend/components/customizer/query-string-builder.tsx @@ -241,15 +241,21 @@ export default function QueryStringBuilder({ const [queryParams, setQueryParams] = useState(() => // For each of the custom query params defined in `exampleParams`, // create empty values in `queryParams`. - Object.entries(exampleParams).reduce((accum, [name, value]) => { - // Custom query params are either string or boolean. Inspect the example - // value to infer which one, and set empty values accordingly. - // Throughout the component, these two types are supported in the same - // manner: by inspecting this value type. - const isStringParam = typeof value === 'string' - accum[name] = isStringParam ? '' : true - return accum - }, {} as { [k: string]: string | boolean }) + Object.entries(exampleParams) + .filter( + // If the example defines a value for one of the standard supported + // options, do not duplicate the corresponding parameter. + ([name]) => !supportedBadgeOptions.some(option => name === option.name) + ) + .reduce((accum, [name, value]) => { + // Custom query params are either string or boolean. Inspect the example + // value to infer which one, and set empty values accordingly. + // Throughout the component, these two types are supported in the same + // manner: by inspecting this value type. + const isStringParam = typeof value === 'string' + accum[name] = isStringParam ? '' : true + return accum + }, {} as { [k: string]: string | boolean }) ) // For each of the standard badge options, create empty values in // `badgeOptions`. When `initialStyle` has been provided, use it. diff --git a/package-lock.json b/package-lock.json index 6b55d29073251..8130b25af7051 100644 --- a/package-lock.json +++ b/package-lock.json @@ -244,12 +244,6 @@ "node-releases": "^1.1.70" } }, - "caniuse-lite": { - "version": "1.0.30001199", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001199.tgz", - "integrity": "sha512-ifbK2eChUCFUwGhlEzIoVwzFt1+iriSjyKKFYNfv6hN34483wyWpLLavYQXhnR036LhkdUYaSDpHg1El++VgHQ==", - "dev": true - }, "chalk": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", @@ -775,12 +769,6 @@ "node-releases": "^1.1.70" } }, - "caniuse-lite": { - "version": "1.0.30001196", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001196.tgz", - "integrity": "sha512-CPvObjD3ovWrNBaXlAIGWmg2gQQuJ5YhuciUOjPRox6hIQttu8O+b51dx6VIpIY9ESd2d0Vac1RKpICdG4rGUg==", - "dev": true - }, "chalk": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", @@ -2420,12 +2408,6 @@ "node-releases": "^1.1.70" } }, - "caniuse-lite": { - "version": "1.0.30001196", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001196.tgz", - "integrity": "sha512-CPvObjD3ovWrNBaXlAIGWmg2gQQuJ5YhuciUOjPRox6hIQttu8O+b51dx6VIpIY9ESd2d0Vac1RKpICdG4rGUg==", - "dev": true - }, "electron-to-chromium": { "version": "1.3.681", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.681.tgz", @@ -9659,12 +9641,6 @@ "postcss-value-parser": "^4.1.0" }, "dependencies": { - "caniuse-lite": { - "version": "1.0.30001196", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001196.tgz", - "integrity": "sha512-CPvObjD3ovWrNBaXlAIGWmg2gQQuJ5YhuciUOjPRox6hIQttu8O+b51dx6VIpIY9ESd2d0Vac1RKpICdG4rGUg==", - "dev": true - }, "postcss-value-parser": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.1.0.tgz", @@ -10357,12 +10333,6 @@ "node-releases": "^1.1.70" } }, - "caniuse-lite": { - "version": "1.0.30001196", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001196.tgz", - "integrity": "sha512-CPvObjD3ovWrNBaXlAIGWmg2gQQuJ5YhuciUOjPRox6hIQttu8O+b51dx6VIpIY9ESd2d0Vac1RKpICdG4rGUg==", - "dev": true - }, "core-js-compat": { "version": "3.9.1", "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.9.1.tgz", @@ -11410,9 +11380,9 @@ } }, "caniuse-lite": { - "version": "1.0.30001051", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001051.tgz", - "integrity": "sha512-sw8UUnTlRevawTMZKN7vpfwSjCBVoiMPlYd8oT2VwNylyPCBdMAUmLGUApnYYTtIm5JXsQegUAY7GPHqgfDzjw==", + "version": "1.0.30001199", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001199.tgz", + "integrity": "sha512-ifbK2eChUCFUwGhlEzIoVwzFt1+iriSjyKKFYNfv6hN34483wyWpLLavYQXhnR036LhkdUYaSDpHg1El++VgHQ==", "dev": true }, "caseless": { @@ -18038,12 +18008,6 @@ } } }, - "caniuse-lite": { - "version": "1.0.30001196", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001196.tgz", - "integrity": "sha512-CPvObjD3ovWrNBaXlAIGWmg2gQQuJ5YhuciUOjPRox6hIQttu8O+b51dx6VIpIY9ESd2d0Vac1RKpICdG4rGUg==", - "dev": true - }, "cli-boxes": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/cli-boxes/-/cli-boxes-2.2.1.tgz",