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
  bf6990ff_74b4_16de_3f09_02909aef4024["urlTransform()"]
  1ee162b1_d232_4846_ef61_0018a3d5f851["error()"]
  bf6990ff_74b4_16de_3f09_02909aef4024 -->|calls| 1ee162b1_d232_4846_ef61_0018a3d5f851
  style bf6990ff_74b4_16de_3f09_02909aef4024 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/docs/app/guides/deployment/terraform/[[...slug]]/page.tsx lines 66–99

const urlTransform: UrlTransformFunction = (url: string) => {
  try {
    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 getBasename = (pathname: string) =>
      pathname.endsWith('.md') ? pathname.replace(/\.md$/, '') : pathname
    const stripLeadingPrefix = (pathname: string) => pathname.replace(/^\//, '')
    const stripLeadingDocs = (pathname: string) => pathname.replace(/^docs\//, '')

    const relativePath = stripLeadingPrefix(getBasename(pathname))

    const page = pageMap.find(
      ({ remoteFile, useRoot }) =>
        (useRoot && `${relativePath}.md` === remoteFile) ||
        (!useRoot && `${stripLeadingDocs(relativePath)}.md` === remoteFile)
    )

    if (page) {
      return 'terraform' + `/${page.slug}` + hash
    }

    // If we don't have this page in our docs, link to GitHub repo
    return `https://github.com/${terraformDocsOrg}/${terraformDocsRepo}/blob/${terraformDocsBranch}${pathname}${hash}`
  } catch (err) {
    console.error('Error transforming markdown URL', err)
    return url
  }
}

Subdomains

Calls

Frequently Asked Questions

What does urlTransform() do?
urlTransform() is a function in the supabase codebase.
What does urlTransform() call?
urlTransform() calls 1 function(s): error.

Analyze Your Own Codebase

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

Try Supermodel Free