MCPcopy Create free account
hub / github.com/appium/appium / normalizeBasePath

Function normalizeBasePath

packages/http-server/lib/server.ts:239–254  ·  view source on GitHub ↗
(basePath: string)

Source from the content-addressed store, hash-verified

237 * @returns Normalized base path
238 */
239export function normalizeBasePath(basePath: string): string {
240 if (typeof basePath !== 'string') {
241 throw new Error(`Invalid path prefix ${JSON.stringify(basePath)}`);
242 }
243
244 // ensure the path prefix does not end in '/', since our method map starts all paths with '/'
245 basePath = basePath.replace(/\/$/, '');
246
247 // likewise, ensure the path prefix does always START with /, unless the path
248 // is empty meaning no base path at all
249 if (basePath !== '' && !basePath.startsWith('/')) {
250 basePath = `/${basePath}`;
251 }
252
253 return basePath;
254}
255
256async function createServer(app: Express, cliArgs?: Partial<ServerArgs>): Promise<HttpServer> {
257 const {sslCertificatePath, sslKeyPath} = cliArgs ?? {};

Callers 4

buildServerOptsFunction · 0.90
serverFunction · 0.85
configureServerFunction · 0.85
server.spec.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected