Home / Function/ normalizeRepository() — vite Function Reference

normalizeRepository() — vite Function Reference

Architecture documentation for the normalizeRepository() function in acknowledgements.data.ts from the vite codebase.

Entity Profile

Dependency Diagram

graph TD
  a85b907b_5d08_2d87_8ec2_a2cca3c7d2c0["normalizeRepository()"]
  217bc23a_2c54_8ca5_016d_7cb941ca23b7["acknowledgements.data.ts"]
  a85b907b_5d08_2d87_8ec2_a2cca3c7d2c0 -->|defined in| 217bc23a_2c54_8ca5_016d_7cb941ca23b7
  c7fe79cf_90ff_1266_2969_1631fc185db0["readPackageInfo()"]
  c7fe79cf_90ff_1266_2969_1631fc185db0 -->|calls| a85b907b_5d08_2d87_8ec2_a2cca3c7d2c0
  style a85b907b_5d08_2d87_8ec2_a2cca3c7d2c0 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

docs/_data/acknowledgements.data.ts lines 128–159

function normalizeRepository(
  repo: PackageJson['repository'],
): string | undefined {
  if (!repo) return undefined

  let url: string
  if (typeof repo === 'string') {
    url = repo
  } else if (repo.url) {
    url = repo.url
  } else {
    return undefined
  }
  url = url
    .replace(/^git\+/, '')
    .replace(/\.git$/, '')
    .replace(/(^|\/)[^/]+?@/, '$1') // remove "user@" from "ssh://user@host.com:..."
    .replace(/(\.[^.]+?):/, '$1/') // change ".com:" to ".com/" from "ssh://user@host.com:..."
    .replace(/^git:\/\//, 'https://')
    .replace(/^ssh:\/\//, 'https://')
  if (url.startsWith('github:')) {
    return `https://github.com/${url.slice(7)}`
  } else if (url.startsWith('gitlab:')) {
    return `https://gitlab.com/${url.slice(7)}`
  } else if (url.startsWith('bitbucket:')) {
    return `https://bitbucket.org/${url.slice(10)}`
  } else if (!url.includes(':') && url.split('/').length === 2) {
    return `https://github.com/${url}`
  } else {
    return url.includes('://') ? url : `https://${url}`
  }
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does normalizeRepository() do?
normalizeRepository() is a function in the vite codebase, defined in docs/_data/acknowledgements.data.ts.
Where is normalizeRepository() defined?
normalizeRepository() is defined in docs/_data/acknowledgements.data.ts at line 128.
What calls normalizeRepository()?
normalizeRepository() is called by 1 function(s): readPackageInfo.

Analyze Your Own Codebase

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

Try Supermodel Free