discoverroute

package
v0.0.281 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 30, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddListToSetString

func AddListToSetString(set map[string]struct{}, list []string) map[string]struct{}

AddListToSetString adds elements from a list of strings to a set of strings.

func CaptureStaticAssetReference added in v0.0.279

func CaptureStaticAssetReference(urls map[string]struct{}, baseURL string, fullURL string, ignoreCrossDomain bool, captureStaticAssets bool) bool

CaptureStaticAssetReference centralizes the static-asset-vs-route decision so every route extractor behaves identically. It reports whether fullURL refers to a static asset (e.g. a PDF, image, or archive), in which case the caller must NOT record it as a route. When it is a static asset and static-asset collection is enabled (and the asset is in scope), the asset is added to the urls set so it surfaces in the StaticAssets output instead. A non-asset URL returns false and is left for the caller to handle as a normal route.

func ExtractDomain

func ExtractDomain(rawURL string, maxDomainLevel int) string

ExtractDomain extracts the domain from a URL up to a specified domain level.

func IsAbsoluteURL

func IsAbsoluteURL(u string) bool

IsAbsoluteURL returns true if the given URL is absolute.

func IsSubdomain

func IsSubdomain(baseURL string, targetURL string) bool

IsSubdomain checks if 'sub' is a subdomain of 'base'.

func IsURLAllowed

func IsURLAllowed(baseURL string, targetURL string, ignoreCrossDomain bool, captureStaticAssets bool) bool

IsURLAllowed checks if a target URL is allowed based on base URL, domain matching, and static-asset policy. When captureStaticAssets is false, static asset URLs (e.g. PDFs, images, archives, and JS bundles) are rejected so they are not recorded as routes or queued for spidering. JS bundle fetching for route discovery is gated separately by MaxBundles in the bundle extractors and intentionally bypasses this allowlist; endpoints discovered inside a bundle are still filtered through IsURLAllowed against the target domain.

func MergeBodyParams

func MergeBodyParams(params1 []*discover.RouteBodyParam, params2 []*discover.RouteBodyParam) []*discover.RouteBodyParam

MergeBodyParams merges two slices of RouteBodyParam, retaining unique params and merging example values.

func MergeQueryParams

func MergeQueryParams(params1 []*discover.RouteQueryParam, params2 []*discover.RouteQueryParam) []*discover.RouteQueryParam

MergeQueryParams merges two slices of RouteQueryParam, retaining unique params and merging example values.

func MergeStaticAssets

func MergeStaticAssets(staticAssets []string) []string

MergeStaticAssets merges static asset URLs, retaining only unique static assets.

func MergeWebRoutes

func MergeWebRoutes(routes []*discover.RouteDetails) []*discover.RouteDetails

MergeWebRoutes merges WebRoutes, retaining only unique routes (by method and URL).

func ParseBodyParams

func ParseBodyParams(postData string) ([]*discover.RouteBodyParam, error)

ParseBodyParams parses body parameters from a JSON or form-urlencoded string into RouteBodyParam structs.

func ParseQueryParams

func ParseQueryParams(reqURL *url.URL) []*discover.RouteQueryParam

ParseQueryParams parses query parameters from a URL into RouteQueryParam structs.

func ResolveURL

func ResolveURL(base, ref string) string

ResolveURL resolves a reference URL relative to a base URL.

func SetToListString

func SetToListString(set map[string]struct{}) []string

SetToListString converts a set of strings to a list of strings.

func SplitURLBaseAndPath added in v0.0.237

func SplitURLBaseAndPath(rawURL string) (string, string, error)

SplitURLBaseAndPath returns the URL origin and escaped path as separate route fields.

func URLRemoveQueryParams

func URLRemoveQueryParams(rawURL string) (string, error)

URLRemoveQueryParams removes query parameters from a URL string.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL