cmd/faucet: improve handling of facebook post url (#21838)

Resolves #21532

Co-authored-by: roger <dengjun@huobi.com>
This commit is contained in:
LieutenantRoger 2020-11-24 17:33:58 +08:00 committed by GitHub
parent ead814616c
commit 6b58409614
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -732,7 +732,10 @@ func authTwitter(url string) (string, string, common.Address, error) {
// returning the username, avatar URL and Ethereum address to fund on success. // returning the username, avatar URL and Ethereum address to fund on success.
func authFacebook(url string) (string, string, common.Address, error) { func authFacebook(url string) (string, string, common.Address, error) {
// Ensure the user specified a meaningful URL, no fancy nonsense // Ensure the user specified a meaningful URL, no fancy nonsense
parts := strings.Split(url, "/") parts := strings.Split(strings.Split(url, "?")[0], "/")
if parts[len(parts)-1] == "" {
parts = parts[0 : len(parts)-1]
}
if len(parts) < 4 || parts[len(parts)-2] != "posts" { if len(parts) < 4 || parts[len(parts)-2] != "posts" {
//lint:ignore ST1005 This error is to be displayed in the browser //lint:ignore ST1005 This error is to be displayed in the browser
return "", "", common.Address{}, errors.New("Invalid Facebook post URL") return "", "", common.Address{}, errors.New("Invalid Facebook post URL")