doUrlReplace() — tailwindcss Function Reference
Architecture documentation for the doUrlReplace() function in urls.ts from the tailwindcss codebase.
Entity Profile
Dependency Diagram
graph TD d4709345_2709_57a6_d676_dab269e86182["doUrlReplace()"] 95a806ab_8556_4112_9786_fda4ff23eeca["urls.ts"] d4709345_2709_57a6_d676_dab269e86182 -->|defined in| 95a806ab_8556_4112_9786_fda4ff23eeca 36fca4a6_2f8c_515f_e349_2ce4e1dac4c7["rewriteCssUrls()"] 36fca4a6_2f8c_515f_e349_2ce4e1dac4c7 -->|calls| d4709345_2709_57a6_d676_dab269e86182 ea271be7_d34b_5dc2_9aad_c5fa1b0713cb["rewriteCssImageSet()"] ea271be7_d34b_5dc2_9aad_c5fa1b0713cb -->|calls| d4709345_2709_57a6_d676_dab269e86182 fbb34b96_d176_2cf2_3b47_efa9e854e835["skipUrlReplacer()"] d4709345_2709_57a6_d676_dab269e86182 -->|calls| fbb34b96_d176_2cf2_3b47_efa9e854e835 style d4709345_2709_57a6_d676_dab269e86182 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/@tailwindcss-node/src/urls.ts lines 119–151
async function doUrlReplace(
rawUrl: string,
matched: string,
replacer: CssUrlReplacer,
funcName: string = 'url',
) {
let wrap = ''
const first = rawUrl[0]
if (first === `"` || first === `'`) {
wrap = first
rawUrl = rawUrl.slice(1, -1)
}
if (skipUrlReplacer(rawUrl)) {
return matched
}
let newUrl = await replacer(rawUrl)
// The new url might need wrapping even if the original did not have it, e.g. if a space was added during replacement
if (wrap === '' && newUrl !== encodeURI(newUrl)) {
wrap = '"'
}
// If wrapping in single quotes and newUrl also contains single quotes, switch to double quotes.
// Give preference to double quotes since SVG inlining converts double quotes to single quotes.
if (wrap === "'" && newUrl.includes("'")) {
wrap = '"'
}
// Escape double quotes if they exist (they also tend to be rarer than single quotes)
if (wrap === '"' && newUrl.includes('"')) {
newUrl = newUrl.replace(nonEscapedDoubleQuoteRE, '\\"')
}
return `${funcName}(${wrap}${newUrl}${wrap})`
}
Domain
Subdomains
Defined In
Calls
Called By
Source
Frequently Asked Questions
What does doUrlReplace() do?
doUrlReplace() is a function in the tailwindcss codebase, defined in packages/@tailwindcss-node/src/urls.ts.
Where is doUrlReplace() defined?
doUrlReplace() is defined in packages/@tailwindcss-node/src/urls.ts at line 119.
What does doUrlReplace() call?
doUrlReplace() calls 1 function(s): skipUrlReplacer.
What calls doUrlReplace()?
doUrlReplace() is called by 2 function(s): rewriteCssImageSet, rewriteCssUrls.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free