diff --git a/__tests__/testURL.ts b/__tests__/testURL.ts index f85cbc19..be247f04 100644 --- a/__tests__/testURL.ts +++ b/__tests__/testURL.ts @@ -1,11 +1,11 @@ // string template function, take input URL string and add a search param -// example: url`http://g.com` => `http://g.com?k1=v1` +// example: url`http://g.com` => `http://g.com?k1="json-value"` export function testURL(strings: TemplateStringsArray, ...values: unknown[]) { const raw = strings.reduce((acc, str, i) => acc + str + (values[i] ?? ''), '') + const GITAKO_ACCESS_TOKEN = process.env.GITAKO_ACCESS_TOKEN + if (!GITAKO_ACCESS_TOKEN) return raw + const url = new URL(raw, 'http://localhost') - url.searchParams.append( - 'gitako-config-accessToken', - JSON.stringify(process.env.GITAKO_ACCESS_TOKEN ?? 'fallback_token'), - ) + url.searchParams.set('gitako-config-accessToken', JSON.stringify(GITAKO_ACCESS_TOKEN)) return url.href }