Skip to content

Commit

Permalink
refactor: opt-in testURL encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
EnixCoda committed Dec 15, 2023
1 parent 69cd8d7 commit 562749d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions __tests__/testURL.ts
Original file line number Diff line number Diff line change
@@ -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
}

1 comment on commit 562749d

@vercel
Copy link

@vercel vercel bot commented on 562749d Dec 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

gitako – ./

gitako-git-develop-enix.vercel.app
gitako.vercel.app
gitako-enix.vercel.app
gitako.enix.one

Please sign in to comment.