doUrlReplace() — tailwindcss Function Reference
Architecture documentation for the doUrlReplace() function in urls.ts from the tailwindcss codebase.
Entity Profile
Dependency Diagram
graph TD 54193b84_0504_58d6_30b4_88f0dca676a8["doUrlReplace()"] e196e78f_ee26_e71e_f9e6_b41f9d8c8b40["rewriteCssUrls()"] e196e78f_ee26_e71e_f9e6_b41f9d8c8b40 -->|calls| 54193b84_0504_58d6_30b4_88f0dca676a8 03f31b9c_dbf2_bdf2_18d8_8b2958a2a30d["rewriteCssImageSet()"] 03f31b9c_dbf2_bdf2_18d8_8b2958a2a30d -->|calls| 54193b84_0504_58d6_30b4_88f0dca676a8 c5a5c285_38e2_ad5e_1381_d39102705362["skipUrlReplacer()"] 54193b84_0504_58d6_30b4_88f0dca676a8 -->|calls| c5a5c285_38e2_ad5e_1381_d39102705362 style 54193b84_0504_58d6_30b4_88f0dca676a8 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
Calls
Called By
Source
Frequently Asked Questions
What does doUrlReplace() do?
doUrlReplace() is a function in the tailwindcss codebase.
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