Skip to content
This repository has been archived by the owner on Aug 23, 2021. It is now read-only.

Commit

Permalink
219 - Adds encodeURIComponent() to branch
Browse files Browse the repository at this point in the history
Pretty straightforward, though it does rely on:
https://github.com/tinacms/teams-serverless/issues/427

to fully work.

Simply takes `options.branch` and runs `encodeURIComponent()` against it:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent
  • Loading branch information
Enigmatical committed May 26, 2021
1 parent 2db6d42 commit 3c52da4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/tina-graphql-gateway/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,15 @@ export class Client {

constructor({ tokenStorage = "MEMORY", ...options }: ServerOptions) {
const _this = this;
/**
* Prevents a CORS-issue when the `branch` has slashes in it.
* https://github.com/tinacms/tina-graphql-gateway/issues/219
*/
const encodedBranch = encodeURIComponent(options.branch);
(this.contentApiUrl =
options.customContentApiUrl ||
`${CONTENT_API_URL}/content/${options.organizationId}/${options.clientId}/github/${options.branch}`),
// `https://content.tinajs.dev/content/${options.organizationId}/${options.clientId}/github/${options.branch}`),
`${CONTENT_API_URL}/content/${options.organizationId}/${options.clientId}/github/${encodedBranch}`),
// `https://content.tinajs.dev/content/${options.organizationId}/${options.clientId}/github/${encodedBranch}`),
(this.clientId = options.clientId);
this.organizationId = options.organizationId;

Expand Down

0 comments on commit 3c52da4

Please sign in to comment.