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