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

Relationship Graph

Source Code

apps/docs/app/guides/graphql/[[...slug]]/page.tsx lines 154–191

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 getRelativePath = () => {
      if (pathname.endsWith('.md')) {
        return pathname.replace(/\.md$/, '')
      }
      if (isAbsolute(url)) {
        return relative(externalSiteUrl.pathname, pathname)
      }
      return pathname
    }

    const relativePath = getRelativePath().replace(/^\//, '')

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

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

    // If we don't have this page in our docs, link to original docs
    return `${externalSite}/${relativePath}${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