Skip to content

Commit

Permalink
Implemented default case to extract second path component as video id…
Browse files Browse the repository at this point in the history
…entifier

#75
  • Loading branch information
SvenTiigi committed Oct 26, 2023
1 parent 1fe4c8b commit fdebe49
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions Sources/Models/YouTubePlayer+Source.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,6 @@ public extension YouTubePlayer.Source {
startSeconds: startSeconds
)
}
case "embed":
// Check if a video identifier is available
if let videoId = url?.pathComponents[safe: 2] {
// Return video source
return .video(
id: videoId,
startSeconds: startSeconds
)
}
case "c", "user":
// Check if a channel name is available
if let channelName = url?.pathComponents[safe: 2] {
Expand All @@ -107,7 +98,7 @@ public extension YouTubePlayer.Source {
name: channelName
)
}
case "v":
default:
// Check if a video identifier is available
if let videoId = url?.pathComponents[safe: 2] {
// Return video source
Expand All @@ -116,8 +107,6 @@ public extension YouTubePlayer.Source {
startSeconds: startSeconds
)
}
default:
break
}
}
// Otherwise return nil
Expand Down

0 comments on commit fdebe49

Please sign in to comment.