|
@@ -4347,18 +4347,29 @@ private extension ViewController {
|
|
|
|
|
|
|
|
private func aiCompanionMeetMeetingCode(from meetURL: URL) -> String? {
|
|
private func aiCompanionMeetMeetingCode(from meetURL: URL) -> String? {
|
|
|
// Typical: https://meet.google.com/abc-defg-hij
|
|
// Typical: https://meet.google.com/abc-defg-hij
|
|
|
|
|
+ // But scheduled events can include trailing slashes and extra segments/query params.
|
|
|
guard let host = meetURL.host?.lowercased(),
|
|
guard let host = meetURL.host?.lowercased(),
|
|
|
host == "meet.google.com" || host.hasSuffix(".meet.google.com") else { return nil }
|
|
host == "meet.google.com" || host.hasSuffix(".meet.google.com") else { return nil }
|
|
|
|
|
|
|
|
- let codeCandidate = meetURL.pathComponents.filter { !$0.isEmpty }.last
|
|
|
|
|
- guard let codeCandidate else { return nil }
|
|
|
|
|
|
|
+ // Prefer path segments (ignoring the "/" components that URL.pathComponents includes).
|
|
|
|
|
+ let rawSegments = meetURL.pathComponents
|
|
|
|
|
+ .map { $0.trimmingCharacters(in: .whitespacesAndNewlines) }
|
|
|
|
|
+ .filter { $0.isEmpty == false && $0 != "/" }
|
|
|
|
|
|
|
|
- // Allow flexible token shapes; Meet codes are usually 3 hyphen-separated chunks.
|
|
|
|
|
- let cleaned = codeCandidate.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
|
|
|
- let parts = cleaned.split(separator: "-")
|
|
|
|
|
- guard parts.count >= 3 else { return nil }
|
|
|
|
|
|
|
+ for segment in rawSegments {
|
|
|
|
|
+ if isValidMeetMeetingCode(segment) {
|
|
|
|
|
+ return segment.lowercased()
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- return cleaned
|
|
|
|
|
|
|
+ // Fallback: handle weird path formats by scanning the trimmed path.
|
|
|
|
|
+ let trimmedPath = meetURL.path.trimmingCharacters(in: CharacterSet(charactersIn: "/"))
|
|
|
|
|
+ if let first = trimmedPath.split(separator: "/").first.map(String.init),
|
|
|
|
|
+ isValidMeetMeetingCode(first) {
|
|
|
|
|
+ return first.lowercased()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return nil
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private func aiCompanionSelectConferenceRecord(for meeting: ScheduledMeeting, from records: [ConferenceRecord]) -> ConferenceRecord? {
|
|
private func aiCompanionSelectConferenceRecord(for meeting: ScheduledMeeting, from records: [ConferenceRecord]) -> ConferenceRecord? {
|