mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-08-24 07:12:18 +10:00
fix(api): support HTTPS job posting fetches (#3267)
This commit is contained in:
@@ -104,6 +104,27 @@ describe("fetchJobPostingText", () => {
|
|||||||
await expect(fetchJobPostingText("https://jobs.example/posting")).resolves.toBe("Senior Engineer");
|
await expect(fetchJobPostingText("https://jobs.example/posting")).resolves.toBe("Senior Engineer");
|
||||||
expect(pinnedAddress).toBe("93.184.216.34");
|
expect(pinnedAddress).toBe("93.184.216.34");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("supports Node lookup calls with all=true", async () => {
|
||||||
|
lookupMock.mockResolvedValue([{ address: "93.184.216.34", family: 4 }]);
|
||||||
|
let lookupResult: unknown;
|
||||||
|
requestMock.mockImplementation((_url, options, callback) => {
|
||||||
|
options.lookup("jobs.example", { all: true }, (_error: Error | null, result: unknown) => {
|
||||||
|
lookupResult = result;
|
||||||
|
});
|
||||||
|
const response = Readable.from([Buffer.from("<html><body>Senior Engineer</body></html>")]) as Readable & {
|
||||||
|
statusCode: number;
|
||||||
|
headers: Record<string, string>;
|
||||||
|
};
|
||||||
|
response.statusCode = 200;
|
||||||
|
response.headers = { "content-type": "text/html" };
|
||||||
|
callback(response);
|
||||||
|
return { on: vi.fn(), end: vi.fn() };
|
||||||
|
});
|
||||||
|
|
||||||
|
await expect(fetchJobPostingText("https://jobs.example/posting")).resolves.toBe("Senior Engineer");
|
||||||
|
expect(lookupResult).toEqual([{ address: "93.184.216.34", family: 4 }]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("autofillInputSchema", () => {
|
describe("autofillInputSchema", () => {
|
||||||
|
|||||||
@@ -163,7 +163,14 @@ function requestJobPosting(parsed: URL, address: ValidatedAddress, signal: Abort
|
|||||||
accept: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
accept: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
||||||
"accept-language": "en-US,en;q=0.9",
|
"accept-language": "en-US,en;q=0.9",
|
||||||
},
|
},
|
||||||
lookup: (_hostname, _options, callback) => callback(null, address.address, address.family),
|
lookup: (_hostname, options, callback) => {
|
||||||
|
if (options.all) {
|
||||||
|
callback(null, [address]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(null, address.address, address.family);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
resolve,
|
resolve,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user