Home / Function/ urlTransform() — supabase Function Reference

urlTransform() — supabase Function Reference

Architecture documentation for the urlTransform() function in page.tsx from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  66d74c0c_73ea_a066_0958_8b1b5e45d668["urlTransform()"]
  a81c7658_9b4f_fc60_f8e0_789f62805e13["WrappersDocs()"]
  a81c7658_9b4f_fc60_f8e0_789f62805e13 -->|calls| 66d74c0c_73ea_a066_0958_8b1b5e45d668
  style 66d74c0c_73ea_a066_0958_8b1b5e45d668 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/docs/app/guides/database/extensions/wrappers/[[...slug]]/page.tsx lines 402–432

const urlTransform: UrlTransformFunction = (url) => {
  try {
    const externalSiteUrl = new URL(externalSite)

    const placeholderHostname = 'placeholder'
    const { hostname, pathname, hash } = new URL(url, `http://${placeholderHostname}`)

    // Don't modify a url with a FQDN or a url that's only a hash
    if (hostname !== placeholderHostname || pathname === '/') {
      return url
    }
    const relativePage = (
      pathname.endsWith('.md')
        ? pathname.replace(/\.md$/, '')
        : relative(externalSiteUrl.pathname, pathname)
    ).replace(/^\//, '')

    const page = pageMap.find(({ remoteFile }) => `${relativePage}.md` === remoteFile)

    // If we have a mapping for this page, use the mapped path
    if (page) {
      return page.slug + hash
    }

    // If we don't have this page in our docs, link to original docs
    return `${externalSite}/${relativePage}${hash}`
  } catch (err) {
    console.error('Error transforming markdown URL', err)
    return url
  }
}

Subdomains

Called By

Frequently Asked Questions

What does urlTransform() do?
urlTransform() is a function in the supabase codebase.
What calls urlTransform()?
urlTransform() is called by 1 function(s): WrappersDocs.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free