Skip to main content
The classifier module is the entry point for every string that flows into GitResolve. It answers two questions: what kind of thing is this input? and what structured data can be extracted from it? All five functions are pure and synchronous — they never perform network requests, making them safe to call in hot paths or batch loops without any async overhead.

classifyInput

Examines a raw string and returns an InputType indicating what kind of candidate input it represents. This is the quickest way to route an unknown string before deciding which heavier pipeline function to invoke.

Parameters

string
required
Any string — a URL, file path, or arbitrary text. The value is trimmed before classification.

Returns

An InputType string literal. The classification logic runs in this order:
"resume_url" is a valid InputType value but classifyInput never returns it — the classifier has no way to distinguish a remote PDF URL from any other portfolio URL without fetching the content. Downstream logic may promote "portfolio" to "resume_url" after inspecting Content-Type.

Examples


parseRepoUrl

Fully parses a GitHub, GitLab, or Bitbucket repository URL into structured fields. Strips .git suffixes and trailing slashes, handles GitLab sub-group paths, and detects pull request / issue contribution links.

Parameters

string
required
An absolute URL. Must be parseable by the WHATWG URL constructor and hosted on github.com, gitlab.com, or bitbucket.org. The www. subdomain variant is not accepted by parseRepoUrl (use parseGitLink for that).

Returns

boolean
true when parsing succeeded and data is populated; false otherwise.
ParsedRepo
Present only when valid is true.
string
Present only when valid is false. Possible values:

Behavior notes

  • .git strippinghttps://github.com/owner/repo.git is treated identically to https://github.com/owner/repo.
  • GitLab sub-groups — The parser walks path segments until it hits a stop marker (-, tree, or blob), so https://gitlab.com/myorg/backend/api-service correctly produces owner: "myorg", repo: "api-service", fullPath: "myorg/backend/api-service".
  • Contribution detection differs by provider:
    • GitHub: /pull/{n}pull_request; /issues/{n}issue
    • GitLab: /-/merge_requests/{n}pull_request; /-/issues/{n}issue
    • Bitbucket: /pull-requests/{n}pull_request; /issues/{n}issue

Examples


Classifies a raw URL from any of the six recognised git provider hostnames into a typed ExtractedGitLink. Unlike parseRepoUrl, this function also handles profile pages, PRs, issues, and the www. subdomain variants. Note that gist.github.com is not in GIT_HOSTS, so gist subdomain URLs return null.

Parameters

string
required
An absolute URL string. Must be parseable by the WHATWG URL constructor. Relative URLs return null.

Returns

An ExtractedGitLink object, or null when the URL should be discarded.
string
For repo links this is the normalized canonical URL from parseRepoUrl. For PR/issue links this is the original rawUrl to preserve the exact contribution reference. For profile links this is rawUrl as-is.
'github' | 'gitlab' | 'bitbucket'
Resolved from the hostname via GIT_HOSTS.
GitLinkType
The classification result. See the table below.
string
The extracted owner username. For most link types this is the first path segment. For "gist" type links (matched when the first path segment is literally gist on github.com), the second path segment is used.
string | undefined
Present when type is 'repo', 'pull_request', or 'issue'.
string | undefined
Present when type is 'pull_request' or 'issue'.

Classification logic

Null cases

parseGitLink returns null (silently discards the URL) when:
  • The URL cannot be parsed, or the hostname is not in GIT_HOSTS
  • The last path segment ends with a static asset extension: .png, .svg, .xml, .json, .ico, .txt, .woff, .woff2, .ttf, .css, .js, .map
  • The first path segment matches a reserved system path for that provider (e.g. features, settings, explore, admin)
  • No path segments at all (bare host URL)

Examples


extractGitUrlsFromText

Scans a block of plain text (or raw HTML) with a regex and returns every unique git provider URL it finds. This is used internally by parseResume and extractLinksFromHtml.

Parameters

string
required
Any arbitrary string — resume text, raw HTML, a markdown document, etc.

Returns

An array of unique, normalised URL strings. Each returned value:
  • Has an https:// prefix (bare github.com/... fragments are promoted)
  • Has trailing slashes stripped
  • Appears only once (the array is deduplicated before returning)
  • Matches only github.com, gitlab.com, or bitbucket.org hostnames
The regex captures at most two path segments beyond the hostname, so https://github.com/owner/repo is captured but https://github.com/owner/repo/blob/main/README.md is truncated to https://github.com/owner/repo. This is intentional — deeper paths are not useful for profile resolution and create noise.

Examples


isGitProviderUrl

Returns true if and only if the URL’s hostname is one of the six recognised git provider hostnames. Useful as a fast filter before calling heavier parsing functions.

Parameters

An absolute URL string. Invalid URLs return false rather than throwing.

Returns

true if the hostname is in GIT_HOSTS, false otherwise. The six recognised hostnames are:

Examples


GIT_HOSTS

A constant lookup map from hostname string to GitProvider. Exported for cases where you need to check or iterate the recognised hosts without importing isGitProviderUrl.

Usage