Преглед изворни кода

Open job listings directly on Apply instead of searching by title.

When a job card has an Indeed URL, Apply loads that link; search fallback is used only when the URL is missing or off-domain.

Co-authored-by: Cursor <cursoragent@cursor.com>
AhtashamShahzad1 пре 2 месеци
родитељ
комит
92f4f98a22
1 измењених фајлова са 9 додато и 7 уклоњено
  1. 9 7
      App for Indeed/Views/DashboardView.swift

+ 9 - 7
App for Indeed/Views/DashboardView.swift

@@ -1026,21 +1026,23 @@ final class DashboardView: NSView, NSTextFieldDelegate, NSSharingServicePickerDe
         presentIndeedJobBrowser(url: Self.resolvedIndeedApplyURL(for: job))
     }
 
-    /// Apply always loads a live Indeed page. Single-job URLs (`/viewjob`, `/pagead`, `/rc/clk`, …) are often expired or incorrectly synthesized by the model and show Indeed’s 404; we only trust **search** URLs whose path is `/jobs`. Otherwise we open a fresh `/jobs?q=<title>` (same regional host when the model provided one).
+    /// Opens the listing’s Indeed URL when present (`/viewjob`, `/rc/clk`, `/jobs`, …). Falls back to `/jobs?q=<title>` only when the URL is missing or not on Indeed.
     private static func resolvedIndeedApplyURL(for job: JobListing) -> URL {
         let title = job.title.trimmingCharacters(in: .whitespacesAndNewlines)
         let raw = job.url?.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
 
+        if !raw.isEmpty,
+           let directURL = URL(string: raw),
+           let host = directURL.host?.lowercased(),
+           isIndeedApplyHost(host) {
+            return directURL
+        }
+
         var preferredHost: String?
-        if !raw.isEmpty, let components = URLComponents(string: raw), let host = components.host {
+        if !raw.isEmpty, let host = URLComponents(string: raw)?.host {
             let lower = host.lowercased()
             if isIndeedApplyHost(lower) {
                 preferredHost = host
-                let pathLower = components.path.lowercased()
-                let isJobsSearchPath = pathLower == "/jobs" || pathLower.hasSuffix("/jobs")
-                if isJobsSearchPath, let url = components.url {
-                    return url
-                }
             }
         }
         return indeedJobsSearchURL(title: title, preferredHost: preferredHost)