-
-
Notifications
You must be signed in to change notification settings - Fork 822
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disallow new lines in paths when checking with
isValidPath
(#6055)
* test * disallow new lines * changeset * typo
- Loading branch information
Showing
3 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
"@graphql-tools/utils": patch | ||
--- | ||
|
||
Disallow new lines in paths when checking with `isValidPath` | ||
|
||
A string may sometimes look like a path but is not (like an SDL of a simple | ||
GraphQL schema). To make sure we don't yield false-positives in such cases, | ||
we disallow new lines in paths (even though most Unix systems support new | ||
lines in file names). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { isValidPath } from '../src/helpers'; | ||
|
||
describe('helpers', () => { | ||
it.each([ | ||
`schema @transport(subgraph: "API", kind: "rest", location: "http://0.0.0.0:4001", headers: "{\"Content-Type\":\"application/json\"}") { | ||
query: Query | ||
mutation: Mutation | ||
subscription: Subscription | ||
}`, | ||
])('should detect "%s" as NOT a valid path', str => { | ||
expect(isValidPath(str)).toBeFalsy(); | ||
}); | ||
|
||
it.each(['file', 'file.tsx', 'some/where/file.tsx', '/some/where/file.tsx'])( | ||
'should detect "%s" as a valid path', | ||
str => { | ||
expect(isValidPath(str)).toBeTruthy(); | ||
}, | ||
); | ||
}); |