buildRegistryItemNameFromRegistry() — ui Function Reference
Architecture documentation for the buildRegistryItemNameFromRegistry() function in search.ts from the ui codebase.
Entity Profile
Dependency Diagram
graph TD 52d1915f_aae4_92b3_79b0_94994822dd9e["buildRegistryItemNameFromRegistry()"] 97050a69_2c4b_4c20_ca72_89be3ec705bd["search.ts"] 52d1915f_aae4_92b3_79b0_94994822dd9e -->|defined in| 97050a69_2c4b_4c20_ca72_89be3ec705bd e6f35579_6ae8_ff1e_5451_66a5bfd635b0["searchRegistries()"] e6f35579_6ae8_ff1e_5451_66a5bfd635b0 -->|calls| 52d1915f_aae4_92b3_79b0_94994822dd9e 8c55f1b9_54df_6127_7749_6c47a9f920bb["isUrl()"] 52d1915f_aae4_92b3_79b0_94994822dd9e -->|calls| 8c55f1b9_54df_6127_7749_6c47a9f920bb style 52d1915f_aae4_92b3_79b0_94994822dd9e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/shadcn/src/registry/search.ts lines 119–174
export function buildRegistryItemNameFromRegistry(
name: string,
registry: string
) {
// If registry is not a URL, return namespace format.
if (!isUrl(registry)) {
return `${registry}/${name}`
}
// Find where the host part ends in the original string.
const protocolEnd = registry.indexOf("://") + 3
const hostEnd = registry.indexOf("/", protocolEnd)
if (hostEnd === -1) {
// No path, check for query params.
const queryStart = registry.indexOf("?", protocolEnd)
if (queryStart !== -1) {
// Has query params but no path.
const beforeQuery = registry.substring(0, queryStart)
const queryAndAfter = registry.substring(queryStart)
// Replace "registry" with itemName in query params only.
const updatedQuery = queryAndAfter.replace(/\bregistry\b/g, name)
return beforeQuery + updatedQuery
}
// No path or query, return as is.
return registry
}
// Split at host boundary.
const hostPart = registry.substring(0, hostEnd)
const pathAndQuery = registry.substring(hostEnd)
// Find all occurrences of "registry" in path and query.
// Replace only the last occurrence in the path segment.
const pathEnd =
pathAndQuery.indexOf("?") !== -1
? pathAndQuery.indexOf("?")
: pathAndQuery.length
const pathOnly = pathAndQuery.substring(0, pathEnd)
const queryAndAfter = pathAndQuery.substring(pathEnd)
// Replace the last occurrence of "registry" in the path.
const lastIndex = pathOnly.lastIndexOf("registry")
let updatedPath = pathOnly
if (lastIndex !== -1) {
updatedPath =
pathOnly.substring(0, lastIndex) +
name +
pathOnly.substring(lastIndex + "registry".length)
}
// Replace all occurrences of "registry" in query params.
const updatedQuery = queryAndAfter.replace(/\bregistry\b/g, name)
return hostPart + updatedPath + updatedQuery
}
Domain
Subdomains
Defined In
Calls
Called By
Source
Frequently Asked Questions
What does buildRegistryItemNameFromRegistry() do?
buildRegistryItemNameFromRegistry() is a function in the ui codebase, defined in packages/shadcn/src/registry/search.ts.
Where is buildRegistryItemNameFromRegistry() defined?
buildRegistryItemNameFromRegistry() is defined in packages/shadcn/src/registry/search.ts at line 119.
What does buildRegistryItemNameFromRegistry() call?
buildRegistryItemNameFromRegistry() calls 1 function(s): isUrl.
What calls buildRegistryItemNameFromRegistry()?
buildRegistryItemNameFromRegistry() is called by 1 function(s): searchRegistries.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free