Created
February 8, 2013 19:48
-
-
Save artcommacode/4741461 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var hostname = url.parse(post.url).hostname; | |
if (hostname.indexOf('vimeo') != -1) { | |
var id = url.parse(post.url).pathname; | |
if (id) { | |
post.type = 'vimeo'; | |
post.videoID = id; | |
} else { | |
post.type = 'link'; | |
} | |
} else if (hostname.indexOf('youtu') != -1) { | |
var query = qs.parse(url.parse(post.url).query); | |
if (query.v) { | |
post.type = 'youtube'; | |
post.videoID = query.v; | |
} else { | |
post.type = 'link'; | |
} | |
} else if (post.url.match(/\.(jpeg|jpg|gif|png)$/) !== null) { | |
post.type = 'image'; | |
} else { | |
post.type = 'link'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment