Added URL submission
This commit is contained in:
22
qurl/qurl.go
22
qurl/qurl.go
@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
type QURL struct {
|
||||
@ -14,6 +15,27 @@ type QURL struct {
|
||||
Browser string
|
||||
}
|
||||
|
||||
func (q *QURL) CheckValid() error {
|
||||
if q == nil {
|
||||
return fmt.Errorf("QURL is nil")
|
||||
}
|
||||
|
||||
if q.URL == "" {
|
||||
return fmt.Errorf("URL may not be empty")
|
||||
}
|
||||
|
||||
u, err := url.Parse(q.URL)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if !u.IsAbs() {
|
||||
return fmt.Errorf("Relative URLs are not allowed")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
const alpha = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
||||
const alphalen = uint64(len(alpha))
|
||||
|
||||
|
Reference in New Issue
Block a user