files

package
v0.0.0-...-41e8347 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MimeTypeAllow = map[string]string{
	".js":    "application/javascript",
	".json":  "application/json",
	".woff":  "font/woff",
	".woff2": "font/woff2",
	".ttf":   "font/ttf",
	".mjs":   "text/javascript",
	".html":  "text/html",
	".txt":   "text/plain",
	".css":   "text/css",
	".csv":   "text/csv",
	".md":    "text/markdown",
	".gif":   "image/gif",
	".ico":   "image/x-icon",
	".jpeg":  "image/jpeg",
	".jpg":   "image/jpeg",
	".png":   "image/png",
	".tiff":  "image/tiff",
	".tif":   "image/tiff",
	".svg":   "image/svg+xml",
}
View Source
var MimeTypeReplace = map[string]bool{
	".js":   true,
	".json": true,
	".mjs":  true,
	".css":  true,
}
View Source
var RegJs = regexp.MustCompile(`['"][\w\.\-_/]+?(\.js)['"]`)
View Source
var RegServiceW = regexp.MustCompile(`(serviceWorker\.register\()['"][\w\-\._/]+?(\.js)['"]`)
View Source
var RegStatic = regexp.MustCompile(`['"][\w.\-/ ]+?(\.(?:js|json|woff2?|ttf|mjs|txt|css|md|gif|ico|jpe?g|png|tiff?|svg))['"]`) //matchear todos las url de js,css,mjs y svg para que sean reemplazados

['"][\w\.\-_/ ]+?((\.js)|(\.json)|(\.woff)|(\.woff2)|(\.ttf)|(\.mjs)|(\.txt)|(\.css)|(\.md)|(\.gif)|(\.ico)|(\.jpeg)|(\.jpg)|(\.png)|(\.tiff)|(\.tif)|(\.svg))['"]`) //matchear todos las url de js,css,mjs y svg para que sean reemplazados regJs: regex to find .js files,regServiceW: regex to find service workers definitions regStatic: regex to find static files urls, files ending in .js,.json,.woff,.woff2,.ttf,.json,.mjs,.txt,.css,.md,.gif,.ico,.jpeg,.jpg, .png, .tiff, .tif, .svg

View Source
var RegURL = regexp.MustCompile("[^a-zA-Z0-9]+")

Functions

func CompressBrotli

func CompressBrotli(data []byte) ([]byte, error)

func CompressZstd

func CompressZstd(data []byte) ([]byte, error)

func CorrectFormatCss

func CorrectFormatCss(content []byte) []byte

before, the script didn't catch this format: url(../img/icons/ic-search.svg) so I will just convert it to url("../img/icons/ic-search.svg")

Types

type HTML

type HTML struct {
	Path            string
	Content         []byte
	ContentBR       []byte
	Checksum        string
	ServiceWorkers  map[string]bool
	DependsFullPath map[string]bool
	DataGenerate    bool
}

HTML contains all info about html like if there is any service worker

type SW

type SW struct {
	FileCaller string //the file url that calls the service workers
	Static
}

SW service worker

type Static

type Static struct {
	Path            string //it's full path
	Name            string
	ChangeContent   bool
	Extension       string
	MimeType        string
	Obfuscate       bool
	Content         staticInfo
	ContentObf      staticInfo
	DependsFullPath map[string]bool
}

Static contains info about the static file like the checksum, its content, and so on

func (Static) SetSW

func (static Static) SetSW(workingPath string, sWorkers map[string]string, staticFiles map[string]Static)

Jump to

Keyboard shortcuts

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