0

I am using google custom search to retrieve images but I want to add From: + site name

I have the following which gives me the full url:

      var imgurl = item.link;

Which that is: https://c1.staticflickr.com/2/1012/1362641756_69b7f29427_b.jpg

How do i only get the first part https://c1.staticflickr.com/

Those urls will be dynamic so i don't know if it will be http or https

downFast
  • 31
  • 1
  • 6
  • 1
    try `console.log(window.location);` You will find everything you need in there, just target the properties you wish to use. `window.location.protocal` and `window.location.hostname` should be what you're looking for. – NewToJS Apr 20 '17 at 09:03
  • 1
    @NewToJS it isn't the url in the address bar but what I got from that variable `var imgurl = item.link;` – downFast Apr 20 '17 at 09:05
  • Ah yes, sorry I read the question wrong. My apologies. Maybe regex will be good for this! – NewToJS Apr 20 '17 at 09:06
  • I already read that answer, this isn't a duplicate, will change the title – downFast Apr 20 '17 at 09:10
  • The answer marked as a duplicate could be used to answer your question. It will only require you to make a few minor changes. – NewToJS Apr 20 '17 at 09:15

0 Answers0