Convert this URL to another format

Hey guys, not really sure how to go about this.

var vimeoURL = "";
          //organic url -

I have that organic URL, and I need to convert it to the vimeoURL format. E.g. I need it to be, not, and I need the /video/ after .com. Could someone help me out? Are there tools online for this to automate this / make it easy?

Ignore the different numbers for the video IDs. Not relevant.

var organicURL = "";
var organicArray = organicURL.split('/');
organicArray[2] = "player." + organicArray[2];
organicArray[4] = organicArray[3];
organicArray[3] = "video";
var vimeoURL = organicArray.join('/');

??? Not tested.




I LOVE YOU. Vimeo API is a huge PITA. Thank you very much!

Glad I could help. I was wondering if there might be an easier way via RegEx.

var organicURL = "";
var vimeoURL = organicURL.replace(/^(https?:\/\/)(\/)(\d+)$/,'$1player.$2video/$3');

I tested this one. It works. And it keeps the protocol (http or https).



@RyanReese, just curious if you tried my regex solution and what you thought of it.

Have a great weekend,


Well I didn’t try your most recent one, because the client decided he wanted something COMPLETELY DIFFERENT. So I wasted 3-4 hours :slight_smile: :slight_smile: . Thanks for your efforts though.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.