Added URL submission

This commit is contained in:
2018-11-17 16:47:39 +00:00
committed by cdramey
parent 412c625916
commit 5c669c8b93
9 changed files with 175 additions and 62 deletions

View File

@ -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))