From e023ed89757c701a5509075bb9dad64f48fe5d83 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Mon, 9 Nov 2015 14:31:43 +0800 Subject: [PATCH] URL.yep_matchProfile --- Yep/AppDelegate.swift | 12 +++++------- Yep/Extensions/NSURL+Yep.swift | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/Yep/AppDelegate.swift b/Yep/AppDelegate.swift index 636f5edf..22a1380e 100644 --- a/Yep/AppDelegate.swift +++ b/Yep/AppDelegate.swift @@ -312,17 +312,15 @@ class AppDelegate: UIResponder, UIApplicationDelegate { private func handleUniversalLink(URL: NSURL) -> Bool { - let matchSharedFeed = URL.yep_matchSharedFeed({ feed in + return URL.yep_matchSharedFeed({ feed in println("matchSharedFeed: \(feed)") + + }) || URL.yep_matchProfile({ + + println("matchProfile") }) - if !matchSharedFeed { - - } - - return true - /* guard let host = URL.host else { return false diff --git a/Yep/Extensions/NSURL+Yep.swift b/Yep/Extensions/NSURL+Yep.swift index 0e37c769..2b870f08 100644 --- a/Yep/Extensions/NSURL+Yep.swift +++ b/Yep/Extensions/NSURL+Yep.swift @@ -51,5 +51,27 @@ extension NSURL { return false } + + // make sure put it in last + + func yep_matchProfile(completion: () -> Void) -> Bool { + + guard let host = host where host == yepHost else { + return false + } + + guard let pathComponents = pathComponents else { + return false + } + + if let username = safeFindElement(pathComponents, index: 1) { + + completion() + + return true + } + + return false + } }