mirror of
https://codeberg.org/VnPower/PixivFE
synced 2024-12-06 19:16:23 +01:00
use urlx.Parse
This commit is contained in:
+5
-3
@@ -10,8 +10,10 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"codeberg.org/vnpower/pixivfe/v2/server/token_manager"
|
||||
"github.com/goware/urlx"
|
||||
"github.com/sethvargo/go-envconfig"
|
||||
|
||||
"codeberg.org/vnpower/pixivfe/v2/server/token_manager"
|
||||
)
|
||||
|
||||
var GlobalConfig ServerConfig
|
||||
@@ -91,7 +93,7 @@ func parseRevision(revision string) (date, hash string, isDirty bool) {
|
||||
|
||||
// validateURL checks if the given URL is valid
|
||||
func validateURL(urlString string, urlType string) (*url.URL, error) {
|
||||
parsedURL, err := url.Parse(urlString)
|
||||
parsedURL, err := urlx.Parse(urlString)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -159,7 +161,7 @@ func (s *ServerConfig) LoadConfig() error {
|
||||
proxyURL, err := validateURL(s.ProxyServer_staging, "Proxy server")
|
||||
if err != nil {
|
||||
log.Printf("[WARNING] Invalid proxy server URL: %v. Falling back to built-in proxy URL.", err)
|
||||
proxyURL, _ = url.Parse(BuiltinProxyUrl) // We know this is valid
|
||||
proxyURL, _ = urlx.Parse(BuiltinProxyUrl) // We know this is valid
|
||||
log.Printf("Proxy server set to: %s\n", BuiltinProxyUrl)
|
||||
} else {
|
||||
log.Printf("Proxy server set to: %s\n", proxyURL.String())
|
||||
|
||||
+3
-1
@@ -83,7 +83,9 @@ func oauth_pkce() (string, string) {
|
||||
return code_verifier, code_challenge
|
||||
}
|
||||
|
||||
func AppAPIRefresh(refresh_token string) {
|
||||
func AppAPIRefresh(refresh_token string) AppAPICredentials {
|
||||
var credentials AppAPICredentials
|
||||
|
||||
var body = []byte(fmt.Sprintf(`client_id=%s&client_secret=%s&grant_type=refresh_token&include_policy=true&refresh_token=%s`, CLIENT_ID, CLIENT_SECRET, refresh_token))
|
||||
req, err := http.NewRequest("POST", AUTH_TOKEN_URL, bytes.NewBuffer(body))
|
||||
if err != nil {
|
||||
|
||||
@@ -9,3 +9,5 @@ This section documents some bad/buggy designs in PixivFE's design, both frontend
|
||||
Current proxied URLs don't have weird characters in them. Hopefully it stays this way.
|
||||
|
||||
Solution: Replace "net/url" with a better third-party module
|
||||
|
||||
Mitigation: replaced `url.Parse` with `urlx.Parse` from `github.com/goware/urlx`
|
||||
|
||||
+3
-3
@@ -15,15 +15,15 @@ The main developer documentation is comprised of the following files:
|
||||
|
||||
2. [Design Flaws](design-flaws.md): Documentation of current design issues in PixivFE, both frontend and backend, with potential solutions.
|
||||
|
||||
3. [Feature Ideas](feature-ideas.md): Proposals for potential features or redesigns that can be implemented into PixivFE, including Pixivision integration, Sketch support, and UI improvements.
|
||||
3. [Roadmap](roadmap.md): Planned features and improvements for PixivFE, categorized by implementation status and priority.
|
||||
|
||||
4. [Guidelines](guidelines.md): Guidelines for code development, including the repository file structure.
|
||||
|
||||
5. [Helpful Resources](helpful-resources.md): External links to materials and resources that can aid in PixivFE development, including other Pixiv-related projects and tools.
|
||||
|
||||
6. [Roadmap](roadmap.md): Planned features and improvements for PixivFE, categorized by implementation status and priority.
|
||||
6. [Testing](testing.md): Information about the current state of testing in PixivFE and considerations for future testing strategies.
|
||||
|
||||
7. [Testing](testing.md): Information about the current state of testing in PixivFE and considerations for future testing strategies.
|
||||
7. [Feature Ideas](feature-ideas.md): Proposals for potential features or redesigns that can be implemented into PixivFE, including Pixivision integration, Sketch support, and UI improvements.
|
||||
|
||||
## Features in development
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ require (
|
||||
github.com/go-faker/faker/v4 v4.5.0
|
||||
github.com/goccy/go-json v0.10.3
|
||||
github.com/gorilla/mux v1.8.1
|
||||
github.com/goware/urlx v0.3.2
|
||||
github.com/hashicorp/go-retryablehttp v0.7.7
|
||||
github.com/oklog/ulid/v2 v2.1.0
|
||||
github.com/playwright-community/playwright-go v0.4501.1
|
||||
@@ -21,6 +22,8 @@ require (
|
||||
|
||||
require (
|
||||
github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53 // indirect
|
||||
github.com/PuerkitoBio/purell v1.1.1 // indirect
|
||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
|
||||
github.com/deckarep/golang-set/v2 v2.6.0 // indirect
|
||||
github.com/go-jose/go-jose/v3 v3.0.3 // indirect
|
||||
github.com/go-stack/stack v1.8.1 // indirect
|
||||
|
||||
@@ -4,6 +4,10 @@ github.com/CloudyKit/jet/v6 v6.2.0 h1:EpcZ6SR9n28BUGtNJSvlBqf90IpjeFr36Tizxhn/oM
|
||||
github.com/CloudyKit/jet/v6 v6.2.0/go.mod h1:d3ypHeIRNo2+XyqnGA8s+aphtcVpjP5hPwP/Lzo7Ro4=
|
||||
github.com/PuerkitoBio/goquery v1.9.2 h1:4/wZksC3KgkQw7SQgkKotmKljk0M6V8TUvA8Wb4yPeE=
|
||||
github.com/PuerkitoBio/goquery v1.9.2/go.mod h1:GHPCaP0ODyyxqcNoFGYlAprUFH81NuRPd0GX3Zu2Mvk=
|
||||
github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI=
|
||||
github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M=
|
||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
|
||||
github.com/andybalholm/cascadia v1.3.2 h1:3Xi6Dw5lHF15JtdcmAHD3i1+T8plmv7BQ/nsViSLyss=
|
||||
github.com/andybalholm/cascadia v1.3.2/go.mod h1:7gtRlve5FxPPgIgX36uWBX58OdBsSS6lUvCFb+h7KvU=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
@@ -26,6 +30,8 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
|
||||
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
|
||||
github.com/goware/urlx v0.3.2 h1:gdoo4kBHlkqZNaf6XlQ12LGtQOmpKJrR04Rc3RnpJEo=
|
||||
github.com/goware/urlx v0.3.2/go.mod h1:h8uwbJy68o+tQXCGZNa9D73WN8n0r9OBae5bUnLcgjw=
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
|
||||
github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k=
|
||||
@@ -72,6 +78,7 @@ golang.org/x/exp v0.0.0-20240823005443-9b4947da3948 h1:kx6Ds3MlpiUHKj7syVnbp57++
|
||||
golang.org/x/exp v0.0.0-20240823005443-9b4947da3948/go.mod h1:akd2r19cwCdwSwWeIdzYQGa/EZZyqcOdwWiwj5L5eKQ=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
|
||||
@@ -8,6 +8,8 @@ import (
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/goware/urlx"
|
||||
|
||||
"codeberg.org/vnpower/pixivfe/v2/config"
|
||||
)
|
||||
|
||||
@@ -22,7 +24,7 @@ func GetImageProxy(r *http.Request) url.URL {
|
||||
if value == "" {
|
||||
// fall through to default case
|
||||
} else {
|
||||
proxyUrl, err := url.Parse(value)
|
||||
proxyUrl, err := urlx.Parse(value)
|
||||
if err != nil {
|
||||
// fall through to default case
|
||||
} else {
|
||||
|
||||
@@ -8,6 +8,8 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/goware/urlx"
|
||||
|
||||
"codeberg.org/vnpower/pixivfe/v2/core"
|
||||
)
|
||||
@@ -139,7 +141,7 @@ func CreatePaginator(base, ending string, current_page, max_page int) HTML {
|
||||
pages += `<div class="pagination-buttons">`
|
||||
{ // "jump to page" <form>
|
||||
hidden_section := ""
|
||||
urlParsed, err := url.Parse(base)
|
||||
urlParsed, err := urlx.Parse(base)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user