Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 100893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T00:40:00+00:00 2026-05-11T00:40:00+00:00

Need a function like: function isGoogleURL(url) { … } that returns true iff URL

  • 0

Need a function like:

function isGoogleURL(url) { ... } 

that returns true iff URL belongs to Google. No false positives; no false negatives.

Luckily there’s this as a reference:

.google.com .google.ad .google.ae .google.com.af .google.com.ag .google.com.ai .google.am .google.it.ao .google.com.ar .google.as .google.at .google.com.au .google.az .google.ba .google.com.bd .google.be .google.bg .google.com.bh .google.bi .google.com.bn .google.com.bo .google.com.br .google.bs .google.co.bw .google.com.by .google.com.bz .google.ca .google.cd .google.cg .google.ch .google.ci .google.co.ck .google.cl .google.cn .google.com.co .google.co.cr .google.com.cu .google.cz .google.de .google.dj .google.dk .google.dm .google.com.do .google.dz .google.com.ec .google.ee .google.com.eg .google.es .google.com.et .google.fi .google.com.fj .google.fm .google.fr .google.ge .google.gg .google.com.gh .google.com.gi .google.gl .google.gm .google.gp .google.gr .google.com.gt .google.gy .google.com.hk .google.hn .google.hr .google.ht .google.hu .google.co.id .google.ie .google.co.il .google.im .google.co.in .google.is .google.it .google.je .google.com.jm .google.jo .google.co.jp .google.co.ke .google.com.kh .google.ki .google.kg .google.co.kr .google.kz .google.la .google.li .google.lk .google.co.ls .google.lt .google.lu .google.lv .google.com.ly .google.co.ma .google.md .google.mn .google.ms .google.com.mt .google.mu .google.mv .google.mw .google.com.mx .google.com.my .google.co.mz .google.com.na .google.com.nf .google.com.ng .google.com.ni .google.nl .google.no .google.com.np .google.nr .google.nu .google.co.nz .google.com.om .google.com.pa .google.com.pe .google.com.ph .google.com.pk .google.pl .google.pn .google.com.pr .google.pt .google.com.py .google.com.qa .google.ro .google.ru .google.rw .google.com.sa .google.com.sb .google.sc .google.se .google.com.sg .google.sh .google.si .google.sk .google.sn .google.sm .google.st .google.com.sv .google.co.th .google.com.tj .google.tk .google.tl .google.tm .google.to .google.com.tr .google.tt .google.com.tw .google.co.tz .google.com.ua .google.co.ug .google.co.uk .google.com.uy .google.co.uz .google.com.vc .google.co.ve .google.vg .google.co.vi .google.com.vn .google.vu .google.ws .google.rs .google.co.za .google.co.zm .google.co.zw .google.cat

Any ideas how to do this elegantly?

Some Clarifications:

  • I need this for a greasemonkey script I wrote that currently only works for google.com (and should work for all other TLDs as well). Here is the script (it modifies Google Reader to work on wide screens better).
  • It should work on URLs that belong to the above domains (not blogger.com, etc.).
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T00:40:00+00:00Added an answer on May 11, 2026 at 12:40 am

    Here is an updated version of Prestaul’s answer which solves the two problems I mentioned in the comment there.

    var GOOGLE_DOMAINS = ([     '.google.com',     '.google.ad',     '.google.ae',     '.google.com.af',     '.google.com.ag',     '.google.com.ai',     '.google.am',     '.google.it.ao',     '.google.com.ar',     '.google.as',     '.google.at',     '.google.com.au',     '.google.az',     '.google.ba',     '.google.com.bd' ]).join('\n');  function isGoogleUrl(url) {     // get the 2nd level domain from the url     var domain = /^https?:\/\/[^\///]*(google\.[^\/\\]+)\//i.exec(url);     if(!domain) return false;      domain = '.'+domain[1];     // create a regex to check to see if the domain is supported     var re = new RegExp('^' + domain.replace(/\./g, '\\.') + '$', 'mi');     return re.test(GOOGLE_DOMAINS); }  alert(isGoogleUrl('http://www.google.ba/the/page.html')); // true alert(isGoogleUrl('http://some_mal_site.com/http://www.google.ba/')); // false alert(isGoogleUrl('https://google.com.au/')); // true alert(isGoogleUrl('http://www.google.com.some_mal_site.com/')); // false alert(isGoogleUrl('http://yahoo.com/')); // false 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 95k
  • Answers 95k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Using reflection in your test. var method = typeof(MyController).GetMethod("MyMethod"); var… May 11, 2026 at 6:59 pm
  • Editorial Team
    Editorial Team added an answer I'd get myself another machine (or a VMWare image), delete… May 11, 2026 at 6:59 pm
  • Editorial Team
    Editorial Team added an answer I believe you'll have to write a script in whatever… May 11, 2026 at 6:59 pm

Related Questions

Need a function like: function isGoogleURL(url) { ... } that returns true iff URL
I have a little math problem. I would like to have a function with
Say i have this PHP code: $FooBar = a string; i then need a
I have a class hierarchy as such: +-- VirtualNode | INode --+ +-- SiteNode
I've been reading many a tutorial/article on unmanaged DLLs in C++. For the life

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.