From 23220641333237a2b8df8983ed33ec4231386557 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Wed, 15 Jun 2022 16:16:25 +0100 Subject: [PATCH] fix: avoid double `//` at end of url (#30) * fix: avoid double `//` at end of url * fix: remove withoutLeadingSlash call --- src/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index 8defc76..fee76dd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,7 +4,7 @@ import https from 'https' import { promisify } from 'util' import { promises as fs } from 'fs' import { networkInterfaces } from 'os' -import { withoutLeadingSlash } from 'ufo' +import { joinURL } from 'ufo' import { cyan, gray, underline, bold } from 'colorette' import type { SelfsignedOptions } from 'selfsigned' import { getPort, GetPortInput } from 'get-port-please' @@ -118,12 +118,12 @@ export async function listen (handle: http.RequestListener, opts: Partial { const add = opts.clipboard ? gray('(copied to clipboard)') : '' const lines = [] - const baseURL = withoutLeadingSlash(options?.baseURL || opts.baseURL || '') + const baseURL = options?.baseURL || opts.baseURL || '' const name = options?.name ? ` (${options.name})` : '' - lines.push(` > Local${name}: ${formatURL(url + baseURL)} ${add}`) + lines.push(` > Local${name}: ${formatURL(joinURL(url, baseURL))} ${add}`) if (isExternal) { for (const ip of getExternalIps()) { - lines.push(` > Network${name}: ${formatURL(url.replace('localhost', ip) + baseURL)}`) + lines.push(` > Network${name}: ${formatURL(joinURL(url.replace('localhost', ip), baseURL))}`) } } // eslint-disable-next-line no-console