Reputation: 15
I am trying to remove the first url in a double url link such as:
http://somewebsite.com/something/#/###/#/http://someotherwebsite.com/
after a page loads. So afterwards, would look something like:
Where # = numbers
Sometimes the first website is a .org or.net. I tried searching and tried ideas but never remove the first full link.
Upvotes: 0
Views: 227
Reputation: 949
Try to extract information with url regex:
var matches = tmp.match(/^(https?\:\/\/[^\/?#]+)(?:[\/?#]|$)/i);
Upvotes: 1
Reputation: 44740
str = "http://" + (str.split('http://')[2]);
Demo -->
http://jsfiddle.net/Em9SU/
Upvotes: 1
Reputation: 970
it's not pretty, but this will get you at least on the correct track:
links = 'http://somewebsite.com/something/#/###/#/http://someotherwebsite.com/'
links = links.split('http')
console.log(links[2])
that will give you the second link (removing the 'http', but from there you can just add it back on and do what you need. It's not pretty, but it doesn't sound like you are looking for an elegant solution
If you want to know more about the split() function, it basically splits (hence the name) a string based on an input (the 'http' in our case). From there you can just traverse through it or do whatever you want with the list.
Upvotes: 0