File tree Expand file tree Collapse file tree
middleware/contextualizers Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,14 +9,17 @@ const explorerUrl = process.env.NODE_ENV === 'production'
99 : 'http://localhost:3000'
1010
1111module . exports = async ( req , res , next ) => {
12+ const currentVersionObj = allVersions [ req . context . currentVersion ]
1213 // ignore requests to non-GraphQL reference paths
13- if ( ! req . path . includes ( '/graphql/' ) ) return next ( )
14-
14+ // and to versions that don't exist
15+ if ( ! req . path . includes ( '/graphql/' ) || ! currentVersionObj ) {
16+ return next ( )
17+ }
1518 // Get the relevant name of the GraphQL schema files for the current version
1619 // For example, free-pro-team@latest corresponds to dotcom,
1720 // enterprise-server@2.22 corresponds to ghes-2.22,
1821 // and github-ae@latest corresponds to ghae
19- const graphqlVersion = allVersions [ req . context . currentVersion ] . miscVersionName
22+ const graphqlVersion = currentVersionObj . miscVersionName
2023
2124 req . context . graphql = {
2225 schemaForCurrentVersion : require ( `../../lib/graphql/static/schema-${ graphqlVersion } ` ) ,
Original file line number Diff line number Diff line change @@ -5,14 +5,18 @@ const nonEnterpriseDefaultVersion = require('../../lib/non-enterprise-default-ve
55const allVersions = require ( '../../lib/all-versions' )
66
77module . exports = async ( req , res , next ) => {
8- if ( ! req . path . includes ( 'webhook' ) ) return next ( )
8+ const currentVersionObj = allVersions [ req . context . currentVersion ]
9+ // ignore requests to non-webhook reference paths
10+ // and to versions that don't exist
11+ if ( ! req . path . includes ( 'webhook' ) || ! currentVersionObj ) {
12+ return next ( )
13+ }
914
1015 // Get the name of the dir under lib/webhooks/static
1116 // For example, free-pro-team@latest corresponds to dotcom,
1217 // enterprise-server@2.22 corresponds to ghes-2.22,
1318 // and github-ae@latest corresponds to ghae
14- if ( ! allVersions [ req . context . currentVersion ] ) return next ( )
15- const webhookPayloadDir = allVersions [ req . context . currentVersion ] . miscVersionName
19+ const webhookPayloadDir = currentVersionObj . miscVersionName
1620
1721 const webhookPayloadsForCurrentVersion = webhookPayloads [ webhookPayloadDir ]
1822
You can’t perform that action at this time.
0 commit comments