reEncode() — astro Function Reference
Architecture documentation for the reEncode() function in transition.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 80ac6187_24ca_368d_b34e_938a0f40539a["reEncode()"] f4a9c12d_07bd_6de6_237f_8553c55f6fef["transition.ts"] 80ac6187_24ca_368d_b34e_938a0f40539a -->|defined in| f4a9c12d_07bd_6de6_237f_8553c55f6fef 76c15535_9f6b_845e_9f22_f5c86e52ea7b["renderTransition()"] 76c15535_9f6b_845e_9f22_f5c86e52ea7b -->|calls| 80ac6187_24ca_368d_b34e_938a0f40539a 2527a613_a18b_f09f_d953_5ec7867c60a5["toString()"] 80ac6187_24ca_368d_b34e_938a0f40539a -->|calls| 2527a613_a18b_f09f_d953_5ec7867c60a5 style 80ac6187_24ca_368d_b34e_938a0f40539a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/runtime/server/transition.ts lines 60–86
function reEncode(s: string) {
let result = '';
let codepoint;
// we work on codepoints that might use more than 16bit, not character codes.
// so the index will often step by 1 as usual or by 2 if the codepoint is greater than 0xFFFF
for (let i = 0; i < s.length; i += (codepoint ?? 0) > 0xffff ? 2 : 1) {
codepoint = s.codePointAt(i);
if (codepoint !== undefined) {
// this should never happen, they said!
// If we find a character in the range \x00 - \x7f that is not one of the reEncodeValidChars,
// we replace it with its hex value escaped by an underscore for decodability (and better readability,
// because most of them are punctuations like ,'"":;_..., and '_' might be a better choice than '-')
// The underscore itself (code 95) is also escaped and encoded as two underscores to avoid
// collisions between original and encoded strings.
// All other values are just copied over
result +=
codepoint < 0x80
? codepoint === 95
? '__'
: (reEncodeValidChars[codepoint] ?? '_' + codepoint.toString(16).padStart(2, '0'))
: String.fromCodePoint(codepoint);
}
}
// Digits and minus sign at the beginning of the string are special, so we simply prepend an underscore
return reEncodeInValidStart[result.codePointAt(0) ?? 0] ? '_' + result : result;
}
Domain
Subdomains
Calls
Called By
Source
Frequently Asked Questions
What does reEncode() do?
reEncode() is a function in the astro codebase, defined in packages/astro/src/runtime/server/transition.ts.
Where is reEncode() defined?
reEncode() is defined in packages/astro/src/runtime/server/transition.ts at line 60.
What does reEncode() call?
reEncode() calls 1 function(s): toString.
What calls reEncode()?
reEncode() is called by 1 function(s): renderTransition.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free