diff --git a/Tusker.xcodeproj/project.pbxproj b/Tusker.xcodeproj/project.pbxproj index 37c8d79d..b08660ef 100644 --- a/Tusker.xcodeproj/project.pbxproj +++ b/Tusker.xcodeproj/project.pbxproj @@ -80,6 +80,7 @@ D6333B372137838300CE884A /* AttributedString+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6333B362137838300CE884A /* AttributedString+Helpers.swift */; }; D6333B772138D94E00CE884A /* ComposeMediaView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6333B762138D94E00CE884A /* ComposeMediaView.swift */; }; D6333B792139AEFD00CE884A /* Date+TimeAgo.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6333B782139AEFD00CE884A /* Date+TimeAgo.swift */; }; + D640D76922BAF5E6004FBE69 /* DomainBlocks.plist in Resources */ = {isa = PBXBuildFile; fileRef = D640D76822BAF5E6004FBE69 /* DomainBlocks.plist */; }; D641C773213CAA25004B4513 /* NotificationsTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D641C772213CAA25004B4513 /* NotificationsTableViewController.swift */; }; D641C777213CAA9E004B4513 /* ActionNotificationTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D641C776213CAA9E004B4513 /* ActionNotificationTableViewCell.swift */; }; D641C779213CAC56004B4513 /* ActionNotificationTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = D641C778213CAC56004B4513 /* ActionNotificationTableViewCell.xib */; }; @@ -314,6 +315,7 @@ D6333B362137838300CE884A /* AttributedString+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AttributedString+Helpers.swift"; sourceTree = ""; }; D6333B762138D94E00CE884A /* ComposeMediaView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComposeMediaView.swift; sourceTree = ""; }; D6333B782139AEFD00CE884A /* Date+TimeAgo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Date+TimeAgo.swift"; sourceTree = ""; }; + D640D76822BAF5E6004FBE69 /* DomainBlocks.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = DomainBlocks.plist; sourceTree = ""; }; D641C772213CAA25004B4513 /* NotificationsTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationsTableViewController.swift; sourceTree = ""; }; D641C776213CAA9E004B4513 /* ActionNotificationTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionNotificationTableViewCell.swift; sourceTree = ""; }; D641C778213CAC56004B4513 /* ActionNotificationTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ActionNotificationTableViewCell.xib; sourceTree = ""; }; @@ -1014,6 +1016,7 @@ D6D4DDD6212518A200E1C4BB /* Assets.xcassets */, D6D4DDD8212518A200E1C4BB /* LaunchScreen.storyboard */, D6D4DDDB212518A200E1C4BB /* Info.plist */, + D640D76822BAF5E6004FBE69 /* DomainBlocks.plist */, ); path = Tusker; sourceTree = ""; @@ -1306,6 +1309,7 @@ D6D4DDD7212518A200E1C4BB /* Assets.xcassets in Resources */, D663625D2135C74800C9CBA2 /* ConversationMainStatusTableViewCell.xib in Resources */, D6A5FAFB217B86CE003DB2D9 /* OnboardingViewController.xib in Resources */, + D640D76922BAF5E6004FBE69 /* DomainBlocks.plist in Resources */, D641C77B213CB017004B4513 /* FollowNotificationTableViewCell.xib in Resources */, D6289E84217B795D0003D1D7 /* LargeImageViewController.xib in Resources */, D663626621360DD700C9CBA2 /* Preferences.storyboard in Resources */, diff --git a/Tusker/DomainBlocks.plist b/Tusker/DomainBlocks.plist new file mode 100644 index 00000000..310ded3b --- /dev/null +++ b/Tusker/DomainBlocks.plist @@ -0,0 +1,7 @@ + + + + + gab\..+ + + diff --git a/Tusker/Screens/Onboarding/OnboardingViewController.swift b/Tusker/Screens/Onboarding/OnboardingViewController.swift index b40d62a3..1b51f1f8 100644 --- a/Tusker/Screens/Onboarding/OnboardingViewController.swift +++ b/Tusker/Screens/Onboarding/OnboardingViewController.swift @@ -17,6 +17,12 @@ protocol OnboardingViewControllerDelegate { class OnboardingViewController: UIViewController { + static var blocks: [NSRegularExpression] = { + guard let path = Bundle.main.path(forResource: "DomainBlocks", ofType: "plist"), + let array = NSArray(contentsOfFile: path) as? [String] else { return [] } + return array.compactMap { try? NSRegularExpression(pattern: $0, options: .caseInsensitive) } + }() + var delegate: OnboardingViewControllerDelegate? @IBOutlet weak var urlTextField: UITextField! @@ -38,7 +44,15 @@ class OnboardingViewController: UIViewController { @IBAction func loginPressed(_ sender: Any) { guard let text = urlTextField.text, let url = URL(string: text), - var components = URLComponents(string: text) else { return } + var components = URLComponents(string: text), + let host = components.host, + !OnboardingViewController.blocks.contains(where: { + $0.numberOfMatches(in: host, range: NSRange(host.startIndex.. 0 + }) else { + return + } + + LocalData.shared.instanceURL = url MastodonController.createClient()