Skip to content

Commit

Permalink
drop /config (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
dferber90 committed Nov 2, 2022
1 parent 5bd4b65 commit 667c121
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/unlucky-moons-share.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@vercel/edge-config': minor
---

drop /config
3 changes: 1 addition & 2 deletions jest/setup.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require('jest-fetch-mock').enableMocks();
require('urlpattern-polyfill');

process.env.EDGE_CONFIG =
'https://edge-config.vercel.com/config/ecfg-1?token=token-1';
process.env.EDGE_CONFIG = 'https://edge-config.vercel.com/ecfg-1?token=token-1';
10 changes: 5 additions & 5 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from './index';

const connectionString = process.env.EDGE_CONFIG;
const baseUrl = 'https://edge-config.vercel.com/config/ecfg-1';
const baseUrl = 'https://edge-config.vercel.com/ecfg-1';

// eslint-disable-next-line jest/require-top-level-describe
beforeEach(() => {
Expand All @@ -21,7 +21,7 @@ describe('default Edge Config', () => {
describe('test conditions', () => {
it('should have an env var called EDGE_CONFIG', () => {
expect(connectionString).toEqual(
'https://edge-config.vercel.com/config/ecfg-1?token=token-1',
'https://edge-config.vercel.com/ecfg-1?token=token-1',
);
});
});
Expand Down Expand Up @@ -306,7 +306,7 @@ describe('default Edge Config', () => {
});
});

describe('/()', () => {
describe('/', () => {
describe('when the request succeeds', () => {
it('should return the digest', async () => {
fetchMock.mockResponse(JSON.stringify({ digest: 'awe1' }));
Expand Down Expand Up @@ -370,8 +370,8 @@ describe('default Edge Config', () => {
describe('createEdgeConfig', () => {
describe('when running without lambda layer or via edge function', () => {
const modifiedConnectionString =
'https://edge-config.vercel.com/config/ecfg-2?token=token-2';
const modifiedBaseUrl = 'https://edge-config.vercel.com/config/ecfg-2';
'https://edge-config.vercel.com/ecfg-2?token=token-2';
const modifiedBaseUrl = 'https://edge-config.vercel.com/ecfg-2';
let edgeConfig: EdgeConfigClient;

beforeEach(() => {
Expand Down
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function clone<T>(value: T): T {
* Parse the edgeConfigId and token from an Edge Config Connection String.
*
* Edge Config Connection Strings look like this:
* https://edge-config.vercel.com/config/<edgeConfigId>?token=<token>
* https://edge-config.vercel.com/<edgeConfigId>?token=<token>
*
* @param text - A potential Edge Config Connection String
* @returns The edgeConfgId and token parsed from the given text or null if
Expand All @@ -74,9 +74,9 @@ export function matchEdgeConfigConnectionString(
const url = new URL(text);
if (url.host !== 'edge-config.vercel.com') return null;
if (url.protocol !== 'https:') return null;
if (!url.pathname.startsWith('/config/ecfg')) return null;
if (!url.pathname.startsWith('/ecfg')) return null;

const edgeConfigId = url.pathname.split('/')[2];
const edgeConfigId = url.pathname.split('/')[1];
if (!edgeConfigId) return null;

const token = url.searchParams.get('token');
Expand Down Expand Up @@ -142,7 +142,7 @@ export function createClient(
if (!connection)
throw new Error('@vercel/edge-config: Invalid connection string provided');

const url = `https://edge-config.vercel.com/config/${connection.edgeConfigId}`;
const url = `https://edge-config.vercel.com/${connection.edgeConfigId}`;
const version = '1'; // version of the edge config read access api we talk to
const headers = { Authorization: `Bearer ${connection.token}` };

Expand Down

0 comments on commit 667c121

Please sign in to comment.