Skip to content

Commit

Permalink
Ignore query string when comparing filepath to include pattern (#1098)
Browse files Browse the repository at this point in the history
Co-authored-by: Alec Aivazis <[email protected]>
  • Loading branch information
jycouet and AlecAivazis committed May 28, 2023
1 parent 8bba6c3 commit cb0310c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/two-vans-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'houdini': patch
---

fix: config.include now checks against files ignoring QueryString
27 changes: 27 additions & 0 deletions packages/houdini/src/lib/config.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { describe, expect, test } from 'vitest'

import { path } from '.'
import { testConfig } from '../test'
import type { PluginMeta } from './config'
import { orderedPlugins, readConfigFile } from './config'

Expand Down Expand Up @@ -79,3 +81,28 @@ test(`orderedPlugins - empty => empty`, async () => {
const o = orderedPlugins([]).map((p) => p.name)
expect(o).toMatchInlineSnapshot('[]')
})

test(`Files that should be included`, async () => {
const config = testConfig()

// defaults
expect(config.includeFile(path.join(process.cwd(), 'src/routes/page.ts'))).toBe(true)
expect(config.includeFile(path.join(process.cwd(), 'src/routes/page.js'))).toBe(true)
expect(config.includeFile(path.join(process.cwd(), 'src/routes/page.gql'))).toBe(true)
expect(config.includeFile(path.join(process.cwd(), 'src/routes/page.graphql'))).toBe(true)

// with some "?"
expect(config.includeFile(path.join(process.cwd(), 'src/routes/page.ts?sentry'))).toBe(true)
expect(config.includeFile(path.join(process.cwd(), 'src/rou?tes/page.ts?sentry'))).toBe(true)
expect(config.includeFile(path.join(process.cwd(), 'src/page.ts?s?e?n?t?r?y'))).toBe(true)
})

test(`Files that should not be included`, async () => {
const config = testConfig()

expect(config.includeFile(path.join(process.cwd(), 'src/routes/test'))).toBe(false)
expect(config.includeFile(path.join(process.cwd(), 'src/routes/test.'))).toBe(false)
expect(config.includeFile(path.join(process.cwd(), 'src/routes/test.jts'))).toBe(false)
expect(config.includeFile(path.join(process.cwd(), 'src/routes/test?'))).toBe(false)
expect(config.includeFile(path.join(process.cwd(), 'src/rou?tes/page.nop?s?e'))).toBe(false)
})
3 changes: 3 additions & 0 deletions packages/houdini/src/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,9 @@ export class Config {
ignore_plugins = false,
}: { root?: string; ignore_plugins?: boolean } = {}
) {
const parsed = path.parse(filepath)
filepath = `${parsed.dir}/${parsed.name}${parsed.ext.split('?')[0]}`

let included = false
// plugins might define custom include logic
for (const plugin of ignore_plugins ? [] : this.plugins) {
Expand Down

0 comments on commit cb0310c

Please sign in to comment.