Add more tests.
This commit is contained in:
parent
289f7ef6ad
commit
c0eb5db6c3
4 changed files with 131 additions and 0 deletions
5
types.go
5
types.go
|
@ -2,6 +2,7 @@ package tgbotapi
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
@ -176,6 +177,10 @@ type MessageEntity struct {
|
|||
|
||||
// ParseURL attempts to parse a URL contained within a MessageEntity.
|
||||
func (entity MessageEntity) ParseURL() (*url.URL, error) {
|
||||
if entity.URL == "" {
|
||||
return nil, errors.New(ErrBadURL)
|
||||
}
|
||||
|
||||
return url.Parse(entity.URL)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue