grok fix: statsig signer chunk locate regex include ~ (0~4v1h2zpw7n0.js); fixes locateSignerChunk not found -> conversations/new 403 anti-bot

This commit is contained in:
2026-07-16 09:37:27 +08:00
parent 60be9201e5
commit 86559eb7fc
2 changed files with 7 additions and 4 deletions
@@ -12,9 +12,9 @@ import (
"context" "context"
"crypto/sha256" "crypto/sha256"
"crypto/sha512" "crypto/sha512"
_ "embed"
"encoding/base64" "encoding/base64"
"encoding/json" "encoding/json"
_ "embed"
"errors" "errors"
"fmt" "fmt"
"io" "io"
@@ -44,8 +44,11 @@ const locateConcurrency = 24
var ( var (
// chunkPathRe matches chunk URLs in the homepage; allChunkRefRe additionally // chunkPathRe matches chunk URLs in the homepage; allChunkRefRe additionally
// matches the loader-manifest's lazy refs (which drop the /_next/ prefix). // matches the loader-manifest's lazy refs (which drop the /_next/ prefix).
chunkPathRe = regexp.MustCompile(`/_next/static/chunks/[a-zA-Z0-9_.\-/]+\.js`) // The Turbopack content-hash alphabet includes '~' (e.g. 0~4v1h2zpw7n0.js) -
allChunkRefRe = regexp.MustCompile(`(?:/_next/)?static/chunks/[a-zA-Z0-9_.\-/]+\.js`) // the signer chunk is frequently one of these, so the class MUST list it or
// the signer is never fetched/located (403 anti-bot, static fallback goes stale).
chunkPathRe = regexp.MustCompile(`/_next/static/chunks/[a-zA-Z0-9_.~\-/]+\.js`)
allChunkRefRe = regexp.MustCompile(`(?:/_next/)?static/chunks/[a-zA-Z0-9_.~\-/]+\.js`)
// goja's parser tries to fetch //# sourceMappingURL=... from disk and errors. // goja's parser tries to fetch //# sourceMappingURL=... from disk and errors.
sourceMapRe = regexp.MustCompile(`(?m)//[#@]\s*sourceMappingURL=\S*`) sourceMapRe = regexp.MustCompile(`(?m)//[#@]\s*sourceMappingURL=\S*`)
@@ -15,7 +15,7 @@ import (
http "github.com/bogdanfinn/fhttp" http "github.com/bogdanfinn/fhttp"
) )
var innerChunkRe = regexp.MustCompile(`static/chunks/[a-zA-Z0-9_.\-/]+\.js`) var innerChunkRe = regexp.MustCompile(`static/chunks/[a-zA-Z0-9_.~\-/]+\.js`)
func hnew(ctx context.Context, url, token string) (*http.Request, error) { func hnew(ctx context.Context, url, token string) (*http.Request, error) {
req, err := http.NewRequest(http.MethodGet, url, nil) req, err := http.NewRequest(http.MethodGet, url, nil)