Documentation
¶
Overview ¶
Package sourcemap fetches and caches JavaScript source maps and resolves minified frames (url, line, column) → original (file, line, function).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsAllowedURL ¶
IsAllowedURL reports whether u has an http or https scheme and its host exactly matches one of the allowedHosts entries. Subdomain-prefix attacks (evil.com/cdn.example.com/...) and suffix attacks (cdn.example.com.evil.io/...) are both rejected by the trailing-slash anchor.
Types ¶
type Frame ¶
type Frame struct {
File string `json:"file"`
Line int `json:"line"`
Column int `json:"column"`
Function string `json:"function,omitempty"`
}
Frame is a resolved original-source location.
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver fetches and caches source maps. Safe for concurrent use.
func NewResolver ¶
NewResolver creates a Resolver. maxSize is the FIFO-by-insertion-time bound (entries evicted oldest-first when full), ttl is per-entry expiry duration, maxBodyBytes caps how many bytes of a source map response are read.
func (*Resolver) Resolve ¶
Resolve takes the URL of a minified JS bundle plus 1-based line and column (matching browser stack-frame convention), fetches its companion .map file, and returns the original frame. Source map URL is derived as jsURL+".map".
The returned Frame.File is the path component of the resolved source: the go-sourcemap library resolves relative source paths against the map URL's origin, so we strip that origin prefix to return a clean relative path.