Skip to content

Commit

Permalink
Do not call split on every request (#3122)
Browse files Browse the repository at this point in the history
  • Loading branch information
ardatan authored Nov 30, 2023
1 parent 3fea19f commit e9a1afe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions packages/graphql-yoga/src/plugins/use-graphiql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ export function useGraphiQL<TServerContext extends Record<string, any>>(
};
return {
async onRequest({ request, serverContext, fetchAPI, endResponse, url }) {
const requestedUrl = request.url.split('?')[0];
if (
shouldRenderGraphiQL(request) &&
(requestedUrl.endsWith(config.graphqlEndpoint) ||
requestedUrl.endsWith(`${config.graphqlEndpoint}/`) ||
(request.url.endsWith(config.graphqlEndpoint) ||
request.url.endsWith(`${config.graphqlEndpoint}/`) ||
url.pathname === config.graphqlEndpoint ||
url.pathname === `${config.graphqlEndpoint}/` ||
getUrlPattern(fetchAPI).test(url))
) {
logger.debug(`Rendering GraphiQL`);
Expand Down
6 changes: 3 additions & 3 deletions packages/graphql-yoga/src/plugins/use-unhandled-route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ export function useUnhandledRoute(args: {
}
return {
onRequest({ request, fetchAPI, endResponse, url }) {
const requestedUrl = request.url.split('?')[0];
if (
!requestedUrl.endsWith(args.graphqlEndpoint) &&
!requestedUrl.endsWith(`${args.graphqlEndpoint}/`) &&
!request.url.endsWith(args.graphqlEndpoint) &&
!request.url.endsWith(`${args.graphqlEndpoint}/`) &&
url.pathname !== args.graphqlEndpoint &&
url.pathname !== `${args.graphqlEndpoint}/` &&
!getUrlPattern(fetchAPI).test(url)
) {
if (
Expand Down

0 comments on commit e9a1afe

Please sign in to comment.