From 13791e63dd37885b48dd954d89bc5cd93cf2b1d5 Mon Sep 17 00:00:00 2001 From: Adam Hani Schakaki Date: Mon, 29 Jun 2015 15:05:09 -0700 Subject: [PATCH] Fix #22 --- YouTubePlayer/YouTubePlayer/YouTubePlayer.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/YouTubePlayer/YouTubePlayer/YouTubePlayer.swift b/YouTubePlayer/YouTubePlayer/YouTubePlayer.swift index 7783880..e1874dc 100644 --- a/YouTubePlayer/YouTubePlayer/YouTubePlayer.swift +++ b/YouTubePlayer/YouTubePlayer/YouTubePlayer.swift @@ -62,6 +62,9 @@ private extension NSURL { } public func videoIDFromYouTubeURL(videoURL: NSURL) -> String? { + if let host = videoURL.host, pathComponents = videoURL.pathComponents where pathComponents.count > 1 && host.hasSuffix("youtu.be") { + return pathComponents[1] as? String + } return videoURL.queryStringComponents()["v"] as? String }