INNER CODE UNIT · Go
cgTokenKey
cc1a2b/JShunter · internal/jshunter/chunkgraph.go:384
func cgTokenKey(body []byte, t Token) string {
switch t.Kind {
case TokString, TokTemplate:
return string(body[t.ValStart:t.ValEnd])
case TokIdent, TokNumber, TokKeyword:
return string(body[t.Start:t.End])
}
return ""
}
// cgBuildChunkURLs assembles the path template captured from a runtime URL
// builder. The canonical shape is prefix + id + separator + hash + extension;
// when a second map is present it names the chunk and the id-to-name map is
// applied first, exactly as the runtime does.
func cgBuildChunkURLs(cap cgCapture, source string) []ChunkRef {
if len(cap.literals) < 2 || len(cap.maps) == 0 {
return nil
}