Skip to content

Job application tracker and AI-powered job search assistant. Helps job seekers manage their search journey with AI resume review, job matching, task logging, and application analytics, all while keeping your data private.

fix(automation): match locations on whole terms so "US" stops matching "Australia"

Khuram Niaz73220513bef2
diff --git a/__tests__/ats-rank.spec.ts b/__tests__/ats-rank.spec.ts
index 583637b..c93e8d8 100644
--- a/__tests__/ats-rank.spec.ts
+++ b/__tests__/ats-rank.spec.ts
@@ -32,6 +32,16 @@ describe("locationMatches", () => {
expect(locationMatches("SF | NYC", ["nyc"])).toBe(true);
expect(locationMatches("San Francisco, CA", ["new york"])).toBe(false);
});
+
+ it("matches whole terms only, never a substring of a longer word", () => {
+ const binance =
+ "Asia, Hong Kong, Taiwan, Taipei, Australia, Brisbane, Australia, Sydney";
+ expect(locationMatches(binance, ["Canada", "US"])).toBe(false);
+ expect(locationMatches("Minsk, Belarus", ["US"])).toBe(false);
+ expect(locationMatches("Houston, TX", ["US"])).toBe(false);
+ expect(locationMatches("New York, US", ["Canada", "US"])).toBe(true);
+ expect(locationMatches("Remote - US", ["US"])).toBe(true);
+ });
});
describe("scoreJob", () => {
diff --git a/src/lib/scraper/ats/rank.ts b/src/lib/scraper/ats/rank.ts
index ed9445f..b3ece66 100644
--- a/src/lib/scraper/ats/rank.ts
+++ b/src/lib/scraper/ats/rank.ts
@@ -63,13 +63,11 @@ export function buildIdf(corpus: JobDetails[]): (term: string) => number {
// Empty preference = no constraint (gate passes all). "Remote" is not special:
// it only matches when the user explicitly lists it as a wanted location.
+// Whole-term, so "US" does not match "aUStralia" / "Belarus" / "Houston".
export function locationMatches(jobLocation: string, wanted: string[]): boolean {
const loc = (jobLocation || "").toLowerCase();
if (!wanted || wanted.length === 0) return true;
- return wanted.some((w) => {
- const ww = w.trim().toLowerCase();
- return ww.length > 0 && loc.includes(ww);
- });
+ return wanted.some((w) => termInText(loc, w));
}
function recencyTiebreak(postedDate?: string): number {