MCPcopy Create free account
hub / github.com/omkarcloud/botasaurus / removeAfterFirstSlash

Function removeAfterFirstSlash

js/botasaurus-server-js/src/api-config.ts:725–744  ·  view source on GitHub ↗

* Removes everything after (and including) the first single slash (/) in a string, * but skips over '//' (double slashes), which are used in protocols like 'http://'. * This is primarily used to extract the base URL (protocol + host) from a full URL. * * Example: * removeAfterFirstSlash("htt

(inputString: string)

Source from the content-addressed store, hash-verified

723 * removeAfterFirstSlash("https://example.com") // "https://example.com"
724 */
725function removeAfterFirstSlash(inputString: string): string {
726 let i = 0;
727 const strLen = inputString.length;
728 while (i < strLen) {
729 const char = inputString[i];
730 if (char === '/') {
731 // Check for double slash (e.g., 'http://')
732 if (i + 1 < strLen && inputString[i + 1] === '/') {
733 i += 2;
734 continue;
735 } else {
736 // Single slash: trim here
737 return inputString.substring(0, i);
738 }
739 }
740 i++;
741 }
742 // No single slash found (or only part of protocol), return the whole input
743 return inputString;
744}
745
746/**
747 * Configuration class for API.

Callers 1

enableKubernetesMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected