Explorar o código

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 hai 2 semanas
pai
achega
92f4f98a22
Modificáronse 1 ficheiros con 9 adicións e 7 borrados
  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
1026 1026
         presentIndeedJobBrowser(url: Self.resolvedIndeedApplyURL(for: job))
1027 1027
     }
1028 1028
 
1029
-    /// 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).
1029
+    /// 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.
1030 1030
     private static func resolvedIndeedApplyURL(for job: JobListing) -> URL {
1031 1031
         let title = job.title.trimmingCharacters(in: .whitespacesAndNewlines)
1032 1032
         let raw = job.url?.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
1033 1033
 
1034
+        if !raw.isEmpty,
1035
+           let directURL = URL(string: raw),
1036
+           let host = directURL.host?.lowercased(),
1037
+           isIndeedApplyHost(host) {
1038
+            return directURL
1039
+        }
1040
+
1034 1041
         var preferredHost: String?
1035
-        if !raw.isEmpty, let components = URLComponents(string: raw), let host = components.host {
1042
+        if !raw.isEmpty, let host = URLComponents(string: raw)?.host {
1036 1043
             let lower = host.lowercased()
1037 1044
             if isIndeedApplyHost(lower) {
1038 1045
                 preferredHost = host
1039
-                let pathLower = components.path.lowercased()
1040
-                let isJobsSearchPath = pathLower == "/jobs" || pathLower.hasSuffix("/jobs")
1041
-                if isJobsSearchPath, let url = components.url {
1042
-                    return url
1043
-                }
1044 1046
             }
1045 1047
         }
1046 1048
         return indeedJobsSearchURL(title: title, preferredHost: preferredHost)