mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-10-13 03:58:33 +00:00
Merge 412da60e6b into 61c9a894a4
This commit is contained in:
commit
3ab094b062
4 changed files with 24 additions and 3 deletions
|
|
@ -545,9 +545,11 @@ export const routesPhase: PipelinePhase<RoutesOutput> = {
|
|||
// Unicode property classes make the boundary cover non-ASCII identifier
|
||||
// characters too — ASCII `\w` would let `caféget('/x')` match `get`
|
||||
// (#1852 review F10).
|
||||
// An optional TypeScript type argument list may sit between the name and
|
||||
// the call (`client.get<User[]>('/x')`).
|
||||
const alternation = [...wrapperNames].map(escapeRegex).join('|');
|
||||
const wrapperCallRegex = new RegExp(
|
||||
`(?<![.\\p{L}\\p{N}_$])(?:${alternation})\\s*\\(\\s*['"\`](/[^'"\`\\s)]+)['"\`]`,
|
||||
`(?<![.\\p{L}\\p{N}_$])(?:${alternation})\\s*(?:<[^()'"\`]*>\\s*)?\\(\\s*['"\`](/[^'"\`\\s)]+)['"\`]`,
|
||||
'gu',
|
||||
);
|
||||
const scanContent = (filePath: string, content: string): void => {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,6 @@ const API_BASE = process.env.API_BASE || '';
|
|||
// `fetch()`, so the parse-phase auto-detector cannot flag it. Listing
|
||||
// "doRequest" in `.gitnexusrc` `fetchWrappers` is what lets the routes phase
|
||||
// trace its consumers (#1589/#1852 residual).
|
||||
export async function doRequest(path: string, opts?: Record<string, unknown>) {
|
||||
return axios.get(`${API_BASE}${path}`, opts);
|
||||
export async function doRequest<T = unknown>(path: string, opts?: Record<string, unknown>) {
|
||||
return axios.get<T>(`${API_BASE}${path}`, opts);
|
||||
}
|
||||
|
|
|
|||
11
gitnexus/test/fixtures/lang-resolution/configurable-fetch-wrapper/pages/TypedThings.tsx
vendored
Normal file
11
gitnexus/test/fixtures/lang-resolution/configurable-fetch-wrapper/pages/TypedThings.tsx
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import { doRequest } from '../lib/http';
|
||||
|
||||
type Thing = { id: number; name: string };
|
||||
|
||||
export default function TypedThings() {
|
||||
const loadThings = async () => {
|
||||
const res = await doRequest<Thing[]>('/api/things');
|
||||
return res.data;
|
||||
};
|
||||
return null;
|
||||
}
|
||||
|
|
@ -42,6 +42,14 @@ describe('Configurable fetch wrapper consumer extraction', () => {
|
|||
expect(thingsEdge).toBeDefined();
|
||||
});
|
||||
|
||||
it('traces a configured wrapper called with type arguments', () => {
|
||||
const edges = getRelationships(withConfig, 'FETCHES');
|
||||
const thingsEdge = edges.find(
|
||||
(e) => e.sourceFilePath.includes('TypedThings') && e.target === '/api/things',
|
||||
);
|
||||
expect(thingsEdge).toBeDefined();
|
||||
});
|
||||
|
||||
it('does NOT match a configured bare name inside a longer non-ASCII identifier (#1852 review F10)', () => {
|
||||
// Accented.tsx calls `cafédoRequest('/api/things')` — `doRequest` preceded by
|
||||
// the non-ASCII letter `é`. The Unicode-aware lookbehind must reject it.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue