MCPcopy Create free account
hub / github.com/pingdotgg/t3code / parseRemoteHost

Function parseRemoteHost

packages/shared/src/sourceControl.ts:136–156  ·  view source on GitHub ↗
(remoteUrl: string)

Source from the content-addressed store, hash-verified

134}
135
136function parseRemoteHost(remoteUrl: string): string | null {
137 const trimmed = remoteUrl.trim();
138 if (trimmed.length === 0) {
139 return null;
140 }
141
142 if (trimmed.startsWith("git@")) {
143 const hostWithPath = trimmed.slice("git@".length);
144 const separatorIndex = hostWithPath.search(/[:/]/);
145 if (separatorIndex <= 0) {
146 return null;
147 }
148 return hostWithPath.slice(0, separatorIndex).toLowerCase();
149 }
150
151 try {
152 return new URL(trimmed).host.toLowerCase();
153 } catch {
154 return null;
155 }
156}
157
158function parseHostName(host: string): string {
159 try {

Calls

no outgoing calls

Tested by

no test coverage detected