mirror of
https://github.com/go-shiori/shiori.git
synced 2025-02-22 23:14:02 +08:00
Fix # in url rendered to %23
This commit is contained in:
parent
65d6ddd495
commit
1baf921b49
4 changed files with 16 additions and 14 deletions
|
@ -16,6 +16,7 @@ import (
|
|||
dt "github.com/RadhiFadlillah/shiori/database"
|
||||
"github.com/RadhiFadlillah/shiori/model"
|
||||
"github.com/RadhiFadlillah/shiori/readability"
|
||||
valid "github.com/asaskevich/govalidator"
|
||||
"github.com/gosuri/uiprogress"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
@ -36,8 +37,8 @@ func (h *cmdHandler) addBookmark(cmd *cobra.Command, args []string) {
|
|||
offline, _ := cmd.Flags().GetBool("offline")
|
||||
|
||||
// Make sure URL valid
|
||||
parsedURL, err := nurl.ParseRequestURI(url)
|
||||
if err != nil || parsedURL.Host == "" {
|
||||
parsedURL, err := nurl.Parse(url)
|
||||
if err != nil || !valid.IsRequestURL(url) {
|
||||
cError.Println("URL is not valid")
|
||||
return
|
||||
}
|
||||
|
@ -231,8 +232,8 @@ func (h *cmdHandler) updateBookmarks(cmd *cobra.Command, args []string) {
|
|||
// Check if --url flag is used
|
||||
if cmd.Flags().Changed("url") {
|
||||
// Make sure URL is valid
|
||||
parsedURL, err := nurl.ParseRequestURI(url)
|
||||
if err != nil || parsedURL.Host == "" {
|
||||
parsedURL, err := nurl.Parse(url)
|
||||
if err != nil || !valid.IsRequestURL(url) {
|
||||
cError.Println("URL is not valid")
|
||||
return
|
||||
}
|
||||
|
@ -299,8 +300,8 @@ func (h *cmdHandler) updateBookmarks(cmd *cobra.Command, args []string) {
|
|||
}
|
||||
|
||||
// Parse URL
|
||||
parsedURL, err := nurl.ParseRequestURI(book.URL)
|
||||
if err != nil || parsedURL.Host == "" {
|
||||
parsedURL, err := nurl.Parse(book.URL)
|
||||
if err != nil || !valid.IsRequestURL(book.URL) {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -616,8 +617,8 @@ func (h *cmdHandler) importBookmarks(cmd *cobra.Command, args []string) {
|
|||
// Save bookmarks to database
|
||||
for _, book := range bookmarks {
|
||||
// Make sure URL valid
|
||||
parsedURL, err := nurl.ParseRequestURI(book.URL)
|
||||
if err != nil || parsedURL.Host == "" {
|
||||
parsedURL, err := nurl.Parse(book.URL)
|
||||
if err != nil || !valid.IsRequestURL(book.URL) {
|
||||
cError.Println("URL is not valid")
|
||||
continue
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import (
|
|||
|
||||
"github.com/RadhiFadlillah/shiori/model"
|
||||
"github.com/RadhiFadlillah/shiori/readability"
|
||||
valid "github.com/asaskevich/govalidator"
|
||||
jwt "github.com/dgrijalva/jwt-go"
|
||||
"github.com/julienschmidt/httprouter"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
|
@ -105,8 +106,8 @@ func (h *webHandler) apiInsertBookmark(w http.ResponseWriter, r *http.Request, p
|
|||
checkError(err)
|
||||
|
||||
// Make sure URL valid
|
||||
parsedURL, err := nurl.ParseRequestURI(book.URL)
|
||||
if err != nil || parsedURL.Host == "" {
|
||||
parsedURL, err := nurl.Parse(book.URL)
|
||||
if err != nil || !valid.IsRequestURL(book.URL) {
|
||||
panic(fmt.Errorf("URL is not valid"))
|
||||
}
|
||||
|
||||
|
@ -322,8 +323,8 @@ func (h *webHandler) apiUpdateCache(w http.ResponseWriter, r *http.Request, ps h
|
|||
defer wg.Done()
|
||||
|
||||
// Parse URL
|
||||
parsedURL, err := nurl.ParseRequestURI(book.URL)
|
||||
if err != nil || parsedURL.Host == "" {
|
||||
parsedURL, err := nurl.Parse(book.URL)
|
||||
if err != nil || !valid.IsRequestURL(book.URL) {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ func (h *webHandler) serveBookmarkCache(w http.ResponseWriter, r *http.Request,
|
|||
},
|
||||
"hostname": func(s string) string {
|
||||
parsed, err := nurl.ParseRequestURI(s)
|
||||
if err != nil || parsed.Host == "" {
|
||||
if err != nil || len(parsed.Scheme) == 0 {
|
||||
return s
|
||||
}
|
||||
|
||||
|
|
|
@ -932,7 +932,7 @@ func toAbsoluteURI(uri string, base *nurl.URL) string {
|
|||
|
||||
// If it is already an absolute URL, return as it is
|
||||
tempURI, err := nurl.ParseRequestURI(uri)
|
||||
if err == nil && tempURI.Host != "" {
|
||||
if err == nil && len(tempURI.Scheme) == 0 {
|
||||
return uri
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue