Skip to content

Commit

Permalink
Make zoom and meet links parser more stable
Browse files Browse the repository at this point in the history
  • Loading branch information
leits committed Jun 3, 2020
1 parent 2ba5ac5 commit 9a74cc0
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions MeetingBar/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import Defaults
import HotKey

struct LinksRegex {
static let meet = try! NSRegularExpression(pattern: #"https://meet.google.com/.*"#)
static let zoom = try! NSRegularExpression(pattern: #"https://zoom.us/j/.*"#)
static let meet = try! NSRegularExpression(pattern: #"https://meet.google.com/[a-z-]+"#)
static let zoom = try! NSRegularExpression(pattern: #"https://([a-z0-9.]+)?zoom.us/j/[a-zA-Z0-9?&=]+"#)
}

enum MeetingServices: String, Codable, CaseIterable {
Expand Down Expand Up @@ -583,18 +583,20 @@ func openEvent(_ event: EKEvent) {
}
let meetLink = getMatch(text: (event.notes)!, regex: LinksRegex.meet)
if let link = meetLink {
let meetURL = URL(string: link)!
if Defaults[.useChromeForMeetLinks] {
openLinkInChrome(meetURL)
} else {
openLinkInDefaultBrowser(meetURL)
if let meetURL = URL(string: link) {
if Defaults[.useChromeForMeetLinks] {
openLinkInChrome(meetURL)
} else {
openLinkInDefaultBrowser(meetURL)
}
}
} else {
NSLog("No meet link for event (\(eventTitle))")
let zoomLink = getMatch(text: (event.notes)!, regex: LinksRegex.zoom)
if let link = zoomLink {
let zoomURL = URL(string: link)!
openLinkInDefaultBrowser(zoomURL)
if let zoomURL = URL(string: link) {
openLinkInDefaultBrowser(zoomURL)
}
}
NSLog("No zoom link for event (\(eventTitle))")
}
Expand Down

0 comments on commit 9a74cc0

Please sign in to comment.