0

For example, i have a url that could be:

http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4 http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.ogg http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mov

I want a function that returns a string containg mp4, or ogg or mov from the url.

How to get mp4, ogg and mov video formats from that string?

Jacs
  • 1,437
  • 4
  • 21
  • 31
  • So… in other words, you want to get the *last three characters* from that string…? – deceze Jan 15 '20 at 11:27
  • No, the string might be longer and more complex, i just want to return the mp4. ogg and mov file types. If it is not of any of these types it should return something. – Jacs Jan 15 '20 at 11:29
  • So, if it's not the *last three characters* of the URL, then what? Make an HTTP request to the URL and check its `Content-Type` response header…? You'll have to give us more of a clue what exactly you're looking for and where that information may be found. – deceze Jan 15 '20 at 11:32
  • My question isnt awnsered there... return filename.split('.').pop(); wont work because there is more than a dot in the string. – Jacs Jan 15 '20 at 11:32
  • 1) There are more answers in that duplicate. 2) `split('.').pop()` works just fine with multiple dots. – deceze Jan 15 '20 at 11:33

0 Answers0