Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Day367:如何判断url中只包含qq.com? #370

Open
qappleh opened this issue Apr 20, 2021 · 1 comment
Open

Day367:如何判断url中只包含qq.com? #370

qappleh opened this issue Apr 20, 2021 · 1 comment

Comments

@qappleh
Copy link
Owner

qappleh commented Apr 20, 2021

例如:

http://www.qq.com // 通过

http://www.qq.com.cn // 不通过

http://www.qq.com/a/b // 通过

http://www.qq.com?a=1 // 通过

http://www.123qq.com?a=1 // 不通过

@qappleh
Copy link
Owner Author

qappleh commented Sep 6, 2021

function check(url){
  if(/^https?:\/\/w+\.qq\.com[^.]*$/.test(url)){
    return true;
  }else{
    return false;
  }
 
}
check('http://www.qq.com')
// true
 
check('http://www.qq.com.cn')
// false
 
check('http://www.qq.com/a/b')
// true
 
check('http://www.qq.com?a=1')
// true
 
check('http://www.123qq.com?a=1')
// false
 
check('http://www.baidu.com?redirect=http://www.qq.com/a')
// false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant