@scalar/oas-utils 0.3.2 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/dist/entities/spec/collection.d.ts +6 -12
- package/dist/entities/spec/collection.d.ts.map +1 -1
- package/dist/entities/spec/collection.js +1 -1
- package/dist/entities/spec/collection.js.map +2 -2
- package/dist/helpers/http-methods.js +9 -9
- package/dist/helpers/http-methods.js.map +1 -1
- package/dist/helpers/pretty-print-json.d.ts.map +1 -1
- package/dist/helpers/pretty-print-json.js.map +2 -2
- package/dist/transforms/import-spec.d.ts +8 -3
- package/dist/transforms/import-spec.d.ts.map +1 -1
- package/dist/transforms/import-spec.js +30 -9
- package/dist/transforms/import-spec.js.map +2 -2
- package/package.json +5 -5
- package/dist/entities/spec/operation.test.js +0 -43
- package/dist/entities/spec/operation.test.js.map +0 -7
- package/dist/entities/spec/parameters.test.js +0 -80
- package/dist/entities/spec/parameters.test.js.map +0 -7
- package/dist/entities/spec/request-example.test.js +0 -633
- package/dist/entities/spec/request-example.test.js.map +0 -7
- package/dist/entities/spec/server.test.js +0 -120
- package/dist/entities/spec/server.test.js.map +0 -7
- package/dist/entities/spec/spec-objects.test.js +0 -205
- package/dist/entities/spec/spec-objects.test.js.map +0 -7
- package/dist/entities/spec/x-scalar-environments.test.js +0 -11
- package/dist/entities/spec/x-scalar-environments.test.js.map +0 -7
- package/dist/entities/spec/x-scalar-secrets.test.js +0 -11
- package/dist/entities/spec/x-scalar-secrets.test.js.map +0 -7
- package/dist/helpers/ensure-protocol.test.js +0 -70
- package/dist/helpers/ensure-protocol.test.js.map +0 -7
- package/dist/helpers/fetch-document.test.js +0 -63
- package/dist/helpers/fetch-document.test.js.map +0 -7
- package/dist/helpers/find-variables.test.js +0 -20
- package/dist/helpers/find-variables.test.js.map +0 -7
- package/dist/helpers/is-defined.test.js +0 -37
- package/dist/helpers/is-defined.test.js.map +0 -7
- package/dist/helpers/is-local-url.test.js +0 -40
- package/dist/helpers/is-local-url.test.js.map +0 -7
- package/dist/helpers/is-valid-url.test.js +0 -17
- package/dist/helpers/is-valid-url.test.js.map +0 -7
- package/dist/helpers/json2xml.test.js +0 -19
- package/dist/helpers/json2xml.test.js.map +0 -7
- package/dist/helpers/make-url-absolute.test.js +0 -61
- package/dist/helpers/make-url-absolute.test.js.map +0 -7
- package/dist/helpers/merge-urls.test.js +0 -339
- package/dist/helpers/merge-urls.test.js.map +0 -7
- package/dist/helpers/normalize-mime-type-object.test.js +0 -53
- package/dist/helpers/normalize-mime-type-object.test.js.map +0 -7
- package/dist/helpers/normalize-mime-type.test.js +0 -33
- package/dist/helpers/normalize-mime-type.test.js.map +0 -7
- package/dist/helpers/omit-undefined-values.test.js +0 -89
- package/dist/helpers/omit-undefined-values.test.js.map +0 -7
- package/dist/helpers/parse.test.js +0 -45
- package/dist/helpers/parse.test.js.map +0 -7
- package/dist/helpers/pretty-print-json.test.js +0 -28
- package/dist/helpers/pretty-print-json.test.js.map +0 -7
- package/dist/helpers/redirect-to-proxy.test.js +0 -54
- package/dist/helpers/redirect-to-proxy.test.js.map +0 -7
- package/dist/helpers/regex-helpers.test.js +0 -154
- package/dist/helpers/regex-helpers.test.js.map +0 -7
- package/dist/helpers/replace-variables.test.js +0 -30
- package/dist/helpers/replace-variables.test.js.map +0 -7
- package/dist/helpers/security/get-schemes.test.js +0 -71
- package/dist/helpers/security/get-schemes.test.js.map +0 -7
- package/dist/helpers/security/has-token.test.js +0 -157
- package/dist/helpers/security/has-token.test.js.map +0 -7
- package/dist/migrations/semver.test.js +0 -21
- package/dist/migrations/semver.test.js.map +0 -7
- package/dist/migrations/v-2.4.0/migration.test.js +0 -90
- package/dist/migrations/v-2.4.0/migration.test.js.map +0 -7
- package/dist/migrations/v-2.5.0/migration.test.js +0 -108
- package/dist/migrations/v-2.5.0/migration.test.js.map +0 -7
- package/dist/spec-getters/get-example-from-schema.test.js +0 -1092
- package/dist/spec-getters/get-example-from-schema.test.js.map +0 -7
- package/dist/spec-getters/get-parameters-from-operation.test.js +0 -178
- package/dist/spec-getters/get-parameters-from-operation.test.js.map +0 -7
- package/dist/spec-getters/get-request-body-from-operation.test.js +0 -289
- package/dist/spec-getters/get-request-body-from-operation.test.js.map +0 -7
- package/dist/transforms/import-spec.test.js +0 -1124
- package/dist/transforms/import-spec.test.js.map +0 -7
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/helpers/merge-urls.test.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * @vitest-environment jsdom\n */\nimport { describe, expect, it } from 'vitest'\n\nimport { combineUrlAndPath, mergeSearchParams, mergeUrls } from './merge-urls'\n\ndescribe('mergeSearchParams', () => {\n it('merges basic params from different sources', () => {\n const base = new URLSearchParams('a=1&b=2')\n const path = new URLSearchParams('c=3')\n const url = new URLSearchParams('d=4')\n\n const result = mergeSearchParams(base, path, url)\n expect(result.toString()).toBe('a=1&b=2&c=3&d=4')\n })\n\n it('later sources overwrite earlier ones completely', () => {\n const base = new URLSearchParams('a=1&b=2')\n const path = new URLSearchParams('b=3')\n const url = new URLSearchParams('b=4')\n\n const result = mergeSearchParams(base, path, url)\n expect(result.toString()).toBe('a=1&b=4')\n })\n\n it('preserves multiple values from the same source', () => {\n const base = new URLSearchParams('a=1&a=2')\n const path = new URLSearchParams('b=3&b=4')\n const url = new URLSearchParams('c=5&c=6')\n\n const result = mergeSearchParams(base, path, url)\n expect(result.toString()).toBe('a=1&a=2&b=3&b=4&c=5&c=6')\n })\n\n it('overwrites multiple values from earlier sources', () => {\n const base = new URLSearchParams('a=1&a=2')\n const path = new URLSearchParams('a=3&a=4')\n const url = new URLSearchParams()\n\n const result = mergeSearchParams(base, path, url)\n expect(result.toString()).toBe('a=3&a=4')\n })\n\n it('handles empty params', () => {\n const base = new URLSearchParams()\n const path = new URLSearchParams('a=1')\n const url = new URLSearchParams()\n\n const result = mergeSearchParams(base, path, url)\n expect(result.toString()).toBe('a=1')\n })\n\n it('handles special characters correctly', () => {\n const base = new URLSearchParams('q=hello world')\n const path = new URLSearchParams('filter=type:123')\n const url = new URLSearchParams('special=@#$%')\n\n const result = mergeSearchParams(base, path, url)\n expect(decodeURIComponent(result.toString())).toBe('q=hello+world&filter=type:123&special=@#$%')\n })\n\n it('handles complex overwriting scenarios', () => {\n const base = new URLSearchParams('a=1&a=2&b=1&c=1')\n const path = new URLSearchParams('b=2&b=3&c=2')\n const url = new URLSearchParams('c=3&c=4')\n\n const result = mergeSearchParams(base, path, url)\n expect(result.toString()).toBe('a=1&a=2&b=2&b=3&c=3&c=4')\n })\n\n it('maintains order of parameters', () => {\n const base = new URLSearchParams('first=1&second=2')\n const path = new URLSearchParams('third=3')\n const url = new URLSearchParams('fourth=4')\n\n const result = mergeSearchParams(base, path, url)\n expect(result.toString()).toBe('first=1&second=2&third=3&fourth=4')\n })\n\n it('handles boolean and numeric values', () => {\n const base = new URLSearchParams('bool=true&num=123')\n const path = new URLSearchParams('bool=false')\n const url = new URLSearchParams('num=456')\n\n const result = mergeSearchParams(base, path, url)\n expect(result.toString()).toBe('bool=false&num=456')\n })\n\n it('handles null and undefined values', () => {\n const base = new URLSearchParams('a=null&b=undefined')\n const path = new URLSearchParams('a=value')\n const url = new URLSearchParams()\n\n const result = mergeSearchParams(base, path, url)\n expect(result.toString()).toBe('a=value&b=undefined')\n })\n\n it('handles empty string values', () => {\n const base = new URLSearchParams('a=&b=value')\n const path = new URLSearchParams('b=')\n const url = new URLSearchParams()\n\n const result = mergeSearchParams(base, path, url)\n expect(result.toString()).toBe('a=&b=')\n })\n\n describe('edge cases', () => {\n it('handles all empty params', () => {\n const result = mergeSearchParams(new URLSearchParams(), new URLSearchParams(), new URLSearchParams())\n expect(result.toString()).toBe('')\n })\n\n it('handles repeated overwrites', () => {\n const base = new URLSearchParams('a=1&a=2')\n const path = new URLSearchParams('a=3')\n const url = new URLSearchParams('a=4&a=5')\n\n const result = mergeSearchParams(base, path, url)\n expect(result.toString()).toBe('a=4&a=5')\n })\n\n it('preserves plus signs in values', () => {\n const base = new URLSearchParams('q=c++')\n const result = mergeSearchParams(base, new URLSearchParams(), new URLSearchParams())\n expect(result.toString()).toBe('q=c++')\n })\n })\n})\n\ndescribe('mergeUrls', () => {\n it('combines simple URL and path', () => {\n const result = mergeUrls('https://api.example.com', '/users')\n expect(result).toBe('https://api.example.com/users')\n })\n\n it('handles query parameters from base URL', () => {\n const result = mergeUrls('https://api.example.com?version=1', '/users')\n expect(result).toBe('https://api.example.com/users?version=1')\n })\n\n it('handles query parameters from path', () => {\n const result = mergeUrls('https://api.example.com', '/users?role=admin')\n expect(result).toBe('https://api.example.com/users?role=admin')\n })\n\n it('handles query parameters from urlParams', () => {\n const params = new URLSearchParams('token=123')\n const result = mergeUrls('https://api.example.com', '/users', params)\n expect(result).toBe('https://api.example.com/users?token=123')\n })\n\n it('merges query parameters from all sources', () => {\n const params = new URLSearchParams('token=123')\n const result = mergeUrls('https://api.example.com?version=1', '/users?role=admin', params)\n expect(result).toBe('https://api.example.com/users?version=1&role=admin&token=123')\n })\n\n it('handles multiple values for same parameter', () => {\n const params = new URLSearchParams([\n ['filter', 'active'],\n ['filter', 'verified'],\n ])\n const result = mergeUrls('https://api.example.com', '/users', params)\n expect(result).toBe('https://api.example.com/users?filter=active&filter=verified')\n })\n\n it('later sources overwrite earlier ones', () => {\n const params = new URLSearchParams('version=3')\n const result = mergeUrls('https://api.example.com?version=1', '/users?version=2', params)\n expect(result).toBe('https://api.example.com/users?version=3')\n })\n\n it('handles URLs with template variables', () => {\n const result = mergeUrls('{protocol}://api.example.com', '/users')\n expect(result).toBe('http://localhost:3000/{protocol}://api.example.com/users')\n })\n\n it('handles URLs with template variables and disableOriginPrefix', () => {\n const result = mergeUrls('{protocol}://api.example.com', '/users', undefined, true)\n expect(result).toBe('{protocol}://api.example.com/users')\n })\n\n it('handles relative URLs', () => {\n const result = mergeUrls('/api', '/users')\n expect(result).toBe('http://localhost:3000/api/users')\n })\n it('handles relative URLs with disableOriginPrefix', () => {\n const result = mergeUrls('/api', '/users', undefined, true)\n expect(result).toBe('/api/users')\n })\n\n describe('path handling', () => {\n it('handles trailing slashes in base URL', () => {\n const result = mergeUrls('https://api.example.com/', '/users')\n expect(result).toBe('https://api.example.com/users')\n })\n\n it('handles leading slashes in path', () => {\n const result = mergeUrls('https://api.example.com', 'users')\n expect(result).toBe('https://api.example.com/users')\n })\n\n it('handles both trailing and leading slashes', () => {\n const result = mergeUrls('https://api.example.com/', '/users/')\n expect(result).toBe('https://api.example.com/users/')\n })\n\n it('handles empty path', () => {\n const result = mergeUrls('https://api.example.com', '')\n expect(result).toBe('https://api.example.com')\n })\n })\n\n describe('query parameter handling', () => {\n it('preserves parameter order', () => {\n const params = new URLSearchParams([\n ['c', '3'],\n ['d', '4'],\n ])\n const result = mergeUrls('https://api.example.com?a=1', '/users?b=2', params)\n expect(result).toBe('https://api.example.com/users?a=1&b=2&c=3&d=4')\n })\n\n it('handles special characters in parameters', () => {\n const params = new URLSearchParams([['q', 'hello world&special=true']])\n const result = mergeUrls('https://api.example.com', '/search', params)\n expect(result).toBe('https://api.example.com/search?q=hello+world%26special%3Dtrue')\n })\n\n it('handles empty parameters', () => {\n const params = new URLSearchParams('empty=')\n const result = mergeUrls('https://api.example.com', '/users', params)\n expect(result).toBe('https://api.example.com/users?empty=')\n })\n\n it('handles null or undefined parameters', () => {\n const params = new URLSearchParams([\n ['null', 'null'],\n ['undefined', 'undefined'],\n ])\n const result = mergeUrls('https://api.example.com', '/users', params)\n expect(result).toBe('https://api.example.com/users?null=null&undefined=undefined')\n })\n })\n\n describe('edge cases', () => {\n it('handles invalid URLs gracefully', () => {\n const result = mergeUrls('not-a-url', '/path')\n expect(result).toBe('http://localhost:3000/not-a-url/path')\n })\n\n it('handles invalid URLs with disableOriginPrefix', () => {\n const result = mergeUrls('not-a-url', '/path', undefined, true)\n expect(result).toBe('not-a-url/path')\n })\n\n it('handles URLs with authentication', () => {\n const result = mergeUrls('https://user:pass@api.example.com', '/users')\n expect(result).toBe('https://user:pass@api.example.com/users')\n })\n\n it('handles URLs with ports', () => {\n const result = mergeUrls('https://api.example.com:8080', '/users')\n expect(result).toBe('https://api.example.com:8080/users')\n })\n\n it('handles complex URLs', () => {\n const params = new URLSearchParams('token=123')\n const result = mergeUrls('https://user:pass@api.example.com:8080?version=1', '/users?role=admin', params)\n expect(result).toBe('https://user:pass@api.example.com:8080/users?version=1&role=admin&token=123')\n })\n })\n\n describe('error handling', () => {\n it('handles empty base url', () => {\n const result = mergeUrls('', '/users')\n expect(result).toBe('/users')\n })\n\n it('handles undefined urlParams', () => {\n const result = mergeUrls('https://api.example.com', '/users', undefined)\n expect(result).toBe('https://api.example.com/users')\n })\n\n it('handles malformed URLs gracefully', () => {\n const result = mergeUrls('http://{bad-url}', '/users')\n expect(result).toBe('http://{bad-url}/users')\n })\n })\n})\n\ndescribe('combineUrlAndPath', () => {\n describe('basic path joining', () => {\n it('combines base and path with single slash', () => {\n expect(combineUrlAndPath('http://example.com', 'api')).toBe('http://example.com/api')\n })\n\n it('returns base when paths are identical', () => {\n expect(combineUrlAndPath('http://example.com', 'http://example.com')).toBe('http://example.com')\n })\n\n it('returns base when path is empty', () => {\n expect(combineUrlAndPath('http://example.com', '')).toBe('http://example.com')\n })\n\n it('returns base when path is undefined', () => {\n expect(combineUrlAndPath('http://example.com', undefined as unknown as string)).toBe('http://example.com')\n })\n })\n\n describe('slash handling', () => {\n it('removes trailing slash from base', () => {\n expect(combineUrlAndPath('http://example.com/', 'api')).toBe('http://example.com/api')\n })\n\n it('removes leading slash from path', () => {\n expect(combineUrlAndPath('http://example.com', '/api')).toBe('http://example.com/api')\n })\n\n it('handles both trailing and leading slashes', () => {\n expect(combineUrlAndPath('http://example.com/', '/api')).toBe('http://example.com/api')\n })\n\n it('removes multiple trailing slashes', () => {\n expect(combineUrlAndPath('http://example.com///', 'api')).toBe('http://example.com/api')\n })\n\n it('removes multiple leading slashes', () => {\n expect(combineUrlAndPath('http://example.com', '///api')).toBe('http://example.com/api')\n })\n\n it('handles multiple slashes in both base and path', () => {\n expect(combineUrlAndPath('http://example.com///', '///api')).toBe('http://example.com/api')\n })\n })\n\n describe('path segments', () => {\n it('preserves multiple path segments', () => {\n expect(combineUrlAndPath('http://example.com', 'api/v1/users')).toBe('http://example.com/api/v1/users')\n })\n\n it('preserves query parameters in base', () => {\n expect(combineUrlAndPath('http://example.com?version=1', 'api')).toBe('http://example.com?version=1/api')\n })\n\n it('preserves query parameters in path', () => {\n expect(combineUrlAndPath('http://example.com', 'api?version=1')).toBe('http://example.com/api?version=1')\n })\n\n it('preserves hash fragments', () => {\n expect(combineUrlAndPath('http://example.com#section', 'api')).toBe('http://example.com#section/api')\n })\n })\n\n describe('special cases', () => {\n it('handles relative base paths', () => {\n expect(combineUrlAndPath('./base', 'api')).toBe('./base/api')\n })\n\n it('handles parent directory references', () => {\n expect(combineUrlAndPath('../base', 'api')).toBe('../base/api')\n })\n\n it('handles absolute paths', () => {\n expect(combineUrlAndPath('/base', 'api')).toBe('/base/api')\n })\n\n it('removes extra spaces', () => {\n expect(combineUrlAndPath('http://example.com ', ' api ')).toBe('http://example.com/api')\n })\n\n it('handles URLs with ports', () => {\n expect(combineUrlAndPath('http://example.com:8080', 'api')).toBe('http://example.com:8080/api')\n })\n\n it('handles URLs with authentication', () => {\n expect(combineUrlAndPath('http://user:pass@example.com', 'api')).toBe('http://user:pass@example.com/api')\n })\n })\n\n describe('template variables', () => {\n it('preserves variables in base', () => {\n expect(combineUrlAndPath('{protocol}://example.com', 'api')).toBe('{protocol}://example.com/api')\n })\n\n it('preserves variables in path', () => {\n expect(combineUrlAndPath('http://example.com', '{version}/api')).toBe('http://example.com/{version}/api')\n })\n\n it('preserves variables in both', () => {\n expect(combineUrlAndPath('{host}/base', '{version}/api')).toBe('{host}/base/{version}/api')\n })\n })\n\n describe('edge cases', () => {\n it('handles empty base', () => {\n expect(combineUrlAndPath('', 'api')).toBe('api')\n })\n\n it('handles no base url', () => {\n expect(combineUrlAndPath('', 'https://example.com/api')).toBe('https://example.com/api')\n })\n\n it('handles both empty strings', () => {\n expect(combineUrlAndPath('', '')).toBe('')\n })\n\n it('handles root paths', () => {\n expect(combineUrlAndPath('http://example.com', '/')).toBe('http://example.com/')\n })\n\n it('handles special characters in paths', () => {\n expect(combineUrlAndPath('http://example.com', 'path with spaces')).toBe('http://example.com/path with spaces')\n })\n\n it('preserves URL encoded characters', () => {\n expect(combineUrlAndPath('http://example.com', 'path%20with%20spaces')).toBe(\n 'http://example.com/path%20with%20spaces',\n )\n })\n })\n})\n"],
|
|
5
|
-
"mappings": "AAGA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,mBAAmB,mBAAmB,iBAAiB;AAEhE,SAAS,qBAAqB,MAAM;AAClC,KAAG,8CAA8C,MAAM;AACrD,UAAM,OAAO,IAAI,gBAAgB,SAAS;AAC1C,UAAM,OAAO,IAAI,gBAAgB,KAAK;AACtC,UAAM,MAAM,IAAI,gBAAgB,KAAK;AAErC,UAAM,SAAS,kBAAkB,MAAM,MAAM,GAAG;AAChD,WAAO,OAAO,SAAS,CAAC,EAAE,KAAK,iBAAiB;AAAA,EAClD,CAAC;AAED,KAAG,mDAAmD,MAAM;AAC1D,UAAM,OAAO,IAAI,gBAAgB,SAAS;AAC1C,UAAM,OAAO,IAAI,gBAAgB,KAAK;AACtC,UAAM,MAAM,IAAI,gBAAgB,KAAK;AAErC,UAAM,SAAS,kBAAkB,MAAM,MAAM,GAAG;AAChD,WAAO,OAAO,SAAS,CAAC,EAAE,KAAK,SAAS;AAAA,EAC1C,CAAC;AAED,KAAG,kDAAkD,MAAM;AACzD,UAAM,OAAO,IAAI,gBAAgB,SAAS;AAC1C,UAAM,OAAO,IAAI,gBAAgB,SAAS;AAC1C,UAAM,MAAM,IAAI,gBAAgB,SAAS;AAEzC,UAAM,SAAS,kBAAkB,MAAM,MAAM,GAAG;AAChD,WAA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AC,EAAE,KAAK,yBAAyB;AAAA,IACzF,CAAC;AAED,OAAG,8BAA8B,MAAM;AACrC,aAAO,kBAAkB,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE;AAAA,IAC3C,CAAC;AAED,OAAG,sBAAsB,MAAM;AAC7B,aAAO,kBAAkB,sBAAsB,GAAG,CAAC,EAAE,KAAK,qBAAqB;AAAA,IACjF,CAAC;AAED,OAAG,uCAAuC,MAAM;AAC9C,aAAO,kBAAkB,sBAAsB,kBAAkB,CAAC,EAAE,KAAK,qCAAqC;AAAA,IAChH,CAAC;AAED,OAAG,oCAAoC,MAAM;AAC3C,aAAO,kBAAkB,sBAAsB,sBAAsB,CAAC,EAAE;AAAA,QACtE;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AACH,CAAC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { normalizeMimeTypeObject } from "./normalize-mime-type-object.js";
|
|
3
|
-
describe("normalizeMimeTypeObject", () => {
|
|
4
|
-
it("removes charset", async () => {
|
|
5
|
-
const content = {
|
|
6
|
-
"application/json; charset=utf-8": {}
|
|
7
|
-
};
|
|
8
|
-
expect(normalizeMimeTypeObject(content)).toMatchObject({
|
|
9
|
-
"application/json": {}
|
|
10
|
-
});
|
|
11
|
-
});
|
|
12
|
-
it("removes semicolon", async () => {
|
|
13
|
-
const content = {
|
|
14
|
-
"application/json;": {}
|
|
15
|
-
};
|
|
16
|
-
expect(normalizeMimeTypeObject(content)).toMatchObject({
|
|
17
|
-
"application/json": {}
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
it("removes whitespace", async () => {
|
|
21
|
-
const content = {
|
|
22
|
-
" application/json ": {}
|
|
23
|
-
};
|
|
24
|
-
expect(normalizeMimeTypeObject(content)).toMatchObject({
|
|
25
|
-
"application/json": {}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
it("removes mimetype variants", async () => {
|
|
29
|
-
const content = {
|
|
30
|
-
"application/problem+json": {}
|
|
31
|
-
};
|
|
32
|
-
expect(normalizeMimeTypeObject(content)).toMatchObject({
|
|
33
|
-
"application/json": {}
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
it("removes mimetype variants with special characters", async () => {
|
|
37
|
-
const content = {
|
|
38
|
-
"application/problem+json": {}
|
|
39
|
-
};
|
|
40
|
-
expect(normalizeMimeTypeObject(content)).toMatchObject({
|
|
41
|
-
"application/json": {}
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
it("removes all the clutter", async () => {
|
|
45
|
-
const content = {
|
|
46
|
-
"application/problem-foobar+json; charset=utf-8": {}
|
|
47
|
-
};
|
|
48
|
-
expect(normalizeMimeTypeObject(content)).toMatchObject({
|
|
49
|
-
"application/json": {}
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
//# sourceMappingURL=normalize-mime-type-object.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/helpers/normalize-mime-type-object.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { normalizeMimeTypeObject } from './normalize-mime-type-object'\n\ndescribe('normalizeMimeTypeObject', () => {\n it('removes charset', async () => {\n const content = {\n 'application/json; charset=utf-8': {},\n }\n\n expect(normalizeMimeTypeObject(content)).toMatchObject({\n 'application/json': {},\n })\n })\n\n it('removes semicolon', async () => {\n const content = {\n 'application/json;': {},\n }\n\n expect(normalizeMimeTypeObject(content)).toMatchObject({\n 'application/json': {},\n })\n })\n\n it('removes whitespace', async () => {\n const content = {\n ' application/json ': {},\n }\n\n expect(normalizeMimeTypeObject(content)).toMatchObject({\n 'application/json': {},\n })\n })\n\n it('removes mimetype variants', async () => {\n const content = {\n 'application/problem+json': {},\n }\n\n expect(normalizeMimeTypeObject(content)).toMatchObject({\n 'application/json': {},\n })\n })\n\n it('removes mimetype variants with special characters', async () => {\n const content = {\n 'application/problem+json': {},\n }\n\n expect(normalizeMimeTypeObject(content)).toMatchObject({\n 'application/json': {},\n })\n })\n\n it('removes all the clutter', async () => {\n const content = {\n 'application/problem-foobar+json; charset=utf-8': {},\n }\n\n expect(normalizeMimeTypeObject(content)).toMatchObject({\n 'application/json': {},\n })\n })\n})\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,+BAA+B;AAExC,SAAS,2BAA2B,MAAM;AACxC,KAAG,mBAAmB,YAAY;AAChC,UAAM,UAAU;AAAA,MACd,mCAAmC,CAAC;AAAA,IACtC;AAEA,WAAO,wBAAwB,OAAO,CAAC,EAAE,cAAc;AAAA,MACrD,oBAAoB,CAAC;AAAA,IACvB,CAAC;AAAA,EACH,CAAC;AAED,KAAG,qBAAqB,YAAY;AAClC,UAAM,UAAU;AAAA,MACd,qBAAqB,CAAC;AAAA,IACxB;AAEA,WAAO,wBAAwB,OAAO,CAAC,EAAE,cAAc;AAAA,MACrD,oBAAoB,CAAC;AAAA,IACvB,CAAC;AAAA,EACH,CAAC;AAED,KAAG,sBAAsB,YAAY;AACnC,UAAM,UAAU;AAAA,MACd,sBAAsB,CAAC;AAAA,IACzB;AAEA,WAAO,wBAAwB,OAAO,CAAC,EAAE,cAAc;AAAA,MACrD,oBAAoB,CAAC;AAAA,IACvB,CAAC;AAAA,EACH,CAAC;AAED,KAAG,6BAA6B,YAAY;AAC1C,UAAM,UAAU;AAAA,MACd,4BAA4B,CAAC;AAAA,IAC/B;AAEA,WAAO,wBAAwB,OAAO,CAAC,EAAE,cAAc;AAAA,MACrD,oBAAoB,CAAC;AAAA,IACvB,CAAC;AAAA,EACH,CAAC;AAED,KAAG,qDAAqD,YAAY;AAClE,UAAM,UAAU;AAAA,MACd,4BAA4B,CAAC;AAAA,IAC/B;AAEA,WAAO,wBAAwB,OAAO,CAAC,EAAE,cAAc;AAAA,MACrD,oBAAoB,CAAC;AAAA,IACvB,CAAC;AAAA,EACH,CAAC;AAED,KAAG,2BAA2B,YAAY;AACxC,UAAM,UAAU;AAAA,MACd,kDAAkD,CAAC;AAAA,IACrD;AAEA,WAAO,wBAAwB,OAAO,CAAC,EAAE,cAAc;AAAA,MACrD,oBAAoB,CAAC;AAAA,IACvB,CAAC;AAAA,EACH,CAAC;AACH,CAAC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { normalizeMimeType } from "./normalize-mime-type.js";
|
|
3
|
-
describe("normalizeMimeType", () => {
|
|
4
|
-
it("removes charset", async () => {
|
|
5
|
-
const content = "application/json; charset=utf-8";
|
|
6
|
-
expect(normalizeMimeType(content)).toBe("application/json");
|
|
7
|
-
});
|
|
8
|
-
it("removes semicolon", async () => {
|
|
9
|
-
const content = "application/json;";
|
|
10
|
-
expect(normalizeMimeType(content)).toBe("application/json");
|
|
11
|
-
});
|
|
12
|
-
it("removes whitespace", async () => {
|
|
13
|
-
const content = " application/json ";
|
|
14
|
-
expect(normalizeMimeType(content)).toBe("application/json");
|
|
15
|
-
});
|
|
16
|
-
it("removes unsupported mimetype variants", async () => {
|
|
17
|
-
const content = "application/problem+json";
|
|
18
|
-
expect(normalizeMimeType(content)).toBe("application/json");
|
|
19
|
-
});
|
|
20
|
-
it("removes all the clutter", async () => {
|
|
21
|
-
const content = "application/problem-foobar+json; charset=utf-8";
|
|
22
|
-
expect(normalizeMimeType(content)).toBe("application/json");
|
|
23
|
-
});
|
|
24
|
-
it("keeps vendor specific mimetypes", async () => {
|
|
25
|
-
const content = "application/vnd.api+json";
|
|
26
|
-
expect(normalizeMimeType(content)).toBe("application/vnd.api+json");
|
|
27
|
-
});
|
|
28
|
-
it("removes all the clutter but keeps vendor specific part", async () => {
|
|
29
|
-
const content = "application/fhir+json; charset=utf-8";
|
|
30
|
-
expect(normalizeMimeType(content)).toBe("application/fhir+json");
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
//# sourceMappingURL=normalize-mime-type.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/helpers/normalize-mime-type.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { normalizeMimeType } from './normalize-mime-type'\n\ndescribe('normalizeMimeType', () => {\n it('removes charset', async () => {\n const content = 'application/json; charset=utf-8'\n\n expect(normalizeMimeType(content)).toBe('application/json')\n })\n\n it('removes semicolon', async () => {\n const content = 'application/json;'\n\n expect(normalizeMimeType(content)).toBe('application/json')\n })\n\n it('removes whitespace', async () => {\n const content = ' application/json '\n\n expect(normalizeMimeType(content)).toBe('application/json')\n })\n\n it('removes unsupported mimetype variants', async () => {\n const content = 'application/problem+json'\n\n expect(normalizeMimeType(content)).toBe('application/json')\n })\n\n it('removes all the clutter', async () => {\n const content = 'application/problem-foobar+json; charset=utf-8'\n\n expect(normalizeMimeType(content)).toBe('application/json')\n })\n\n it('keeps vendor specific mimetypes', async () => {\n const content = 'application/vnd.api+json'\n\n expect(normalizeMimeType(content)).toBe('application/vnd.api+json')\n })\n\n it('removes all the clutter but keeps vendor specific part', async () => {\n const content = 'application/fhir+json; charset=utf-8'\n\n expect(normalizeMimeType(content)).toBe('application/fhir+json')\n })\n})\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,yBAAyB;AAElC,SAAS,qBAAqB,MAAM;AAClC,KAAG,mBAAmB,YAAY;AAChC,UAAM,UAAU;AAEhB,WAAO,kBAAkB,OAAO,CAAC,EAAE,KAAK,kBAAkB;AAAA,EAC5D,CAAC;AAED,KAAG,qBAAqB,YAAY;AAClC,UAAM,UAAU;AAEhB,WAAO,kBAAkB,OAAO,CAAC,EAAE,KAAK,kBAAkB;AAAA,EAC5D,CAAC;AAED,KAAG,sBAAsB,YAAY;AACnC,UAAM,UAAU;AAEhB,WAAO,kBAAkB,OAAO,CAAC,EAAE,KAAK,kBAAkB;AAAA,EAC5D,CAAC;AAED,KAAG,yCAAyC,YAAY;AACtD,UAAM,UAAU;AAEhB,WAAO,kBAAkB,OAAO,CAAC,EAAE,KAAK,kBAAkB;AAAA,EAC5D,CAAC;AAED,KAAG,2BAA2B,YAAY;AACxC,UAAM,UAAU;AAEhB,WAAO,kBAAkB,OAAO,CAAC,EAAE,KAAK,kBAAkB;AAAA,EAC5D,CAAC;AAED,KAAG,mCAAmC,YAAY;AAChD,UAAM,UAAU;AAEhB,WAAO,kBAAkB,OAAO,CAAC,EAAE,KAAK,0BAA0B;AAAA,EACpE,CAAC;AAED,KAAG,0DAA0D,YAAY;AACvE,UAAM,UAAU;AAEhB,WAAO,kBAAkB,OAAO,CAAC,EAAE,KAAK,uBAAuB;AAAA,EACjE,CAAC;AACH,CAAC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { omitUndefinedValues } from "./omit-undefined-values.js";
|
|
3
|
-
describe("omitUndefinedValues", () => {
|
|
4
|
-
it("removes undefined values from flat objects", () => {
|
|
5
|
-
const input = {
|
|
6
|
-
name: "test",
|
|
7
|
-
description: void 0,
|
|
8
|
-
value: 123,
|
|
9
|
-
empty: void 0
|
|
10
|
-
};
|
|
11
|
-
const result = omitUndefinedValues(input);
|
|
12
|
-
expect(result).toEqual({
|
|
13
|
-
name: "test",
|
|
14
|
-
value: 123
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
it("preserves null values", () => {
|
|
18
|
-
const input = {
|
|
19
|
-
name: "test",
|
|
20
|
-
description: null,
|
|
21
|
-
value: void 0
|
|
22
|
-
};
|
|
23
|
-
const result = omitUndefinedValues(input);
|
|
24
|
-
expect(result).toEqual({
|
|
25
|
-
name: "test",
|
|
26
|
-
description: null
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
it("handles nested objects", () => {
|
|
30
|
-
const input = {
|
|
31
|
-
name: "test",
|
|
32
|
-
metadata: {
|
|
33
|
-
description: void 0,
|
|
34
|
-
tags: ["a", "b"],
|
|
35
|
-
settings: {
|
|
36
|
-
enabled: true,
|
|
37
|
-
config: void 0
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
const result = omitUndefinedValues(input);
|
|
42
|
-
expect(result).toEqual({
|
|
43
|
-
name: "test",
|
|
44
|
-
metadata: {
|
|
45
|
-
tags: ["a", "b"],
|
|
46
|
-
settings: {
|
|
47
|
-
enabled: true
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
it("handles empty objects", () => {
|
|
53
|
-
const input = {};
|
|
54
|
-
const result = omitUndefinedValues(input);
|
|
55
|
-
expect(result).toEqual({});
|
|
56
|
-
});
|
|
57
|
-
it("preserves arrays", () => {
|
|
58
|
-
const input = {
|
|
59
|
-
items: [
|
|
60
|
-
{ id: 1, name: "first", description: void 0 },
|
|
61
|
-
{ id: 2, name: "second", value: void 0 }
|
|
62
|
-
]
|
|
63
|
-
};
|
|
64
|
-
const result = omitUndefinedValues(input);
|
|
65
|
-
expect(result).toEqual({
|
|
66
|
-
items: [
|
|
67
|
-
{ id: 1, name: "first" },
|
|
68
|
-
{ id: 2, name: "second" }
|
|
69
|
-
]
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
it("preserves falsy values except undefined", () => {
|
|
73
|
-
const input = {
|
|
74
|
-
zero: 0,
|
|
75
|
-
empty: "",
|
|
76
|
-
falsy: false,
|
|
77
|
-
nullish: null,
|
|
78
|
-
notDefined: void 0
|
|
79
|
-
};
|
|
80
|
-
const result = omitUndefinedValues(input);
|
|
81
|
-
expect(result).toEqual({
|
|
82
|
-
zero: 0,
|
|
83
|
-
empty: "",
|
|
84
|
-
falsy: false,
|
|
85
|
-
nullish: null
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
//# sourceMappingURL=omit-undefined-values.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/helpers/omit-undefined-values.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { describe, expect, it } from 'vitest'\nimport { omitUndefinedValues } from './omit-undefined-values'\n\ndescribe('omitUndefinedValues', () => {\n it('removes undefined values from flat objects', () => {\n const input = {\n name: 'test',\n description: undefined,\n value: 123,\n empty: undefined,\n }\n\n const result = omitUndefinedValues(input)\n\n expect(result).toEqual({\n name: 'test',\n value: 123,\n })\n })\n\n it('preserves null values', () => {\n const input = {\n name: 'test',\n description: null,\n value: undefined,\n }\n\n const result = omitUndefinedValues(input)\n\n expect(result).toEqual({\n name: 'test',\n description: null,\n })\n })\n\n it('handles nested objects', () => {\n const input = {\n name: 'test',\n metadata: {\n description: undefined,\n tags: ['a', 'b'],\n settings: {\n enabled: true,\n config: undefined,\n },\n },\n }\n\n const result = omitUndefinedValues(input)\n\n expect(result).toEqual({\n name: 'test',\n metadata: {\n tags: ['a', 'b'],\n settings: {\n enabled: true,\n },\n },\n })\n })\n\n it('handles empty objects', () => {\n const input = {}\n\n const result = omitUndefinedValues(input)\n\n expect(result).toEqual({})\n })\n\n it('preserves arrays', () => {\n const input = {\n items: [\n { id: 1, name: 'first', description: undefined },\n { id: 2, name: 'second', value: undefined },\n ],\n }\n\n const result = omitUndefinedValues(input)\n\n expect(result).toEqual({\n items: [\n { id: 1, name: 'first' },\n { id: 2, name: 'second' },\n ],\n })\n })\n\n it('preserves falsy values except undefined', () => {\n const input = {\n zero: 0,\n empty: '',\n falsy: false,\n nullish: null,\n notDefined: undefined,\n }\n\n const result = omitUndefinedValues(input)\n\n expect(result).toEqual({\n zero: 0,\n empty: '',\n falsy: false,\n nullish: null,\n })\n })\n})\n"],
|
|
5
|
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;AAAA,QACL,EAAE,IAAI,GAAG,MAAM,SAAS,aAAa,OAAU;AAAA,QAC/C,EAAE,IAAI,GAAG,MAAM,UAAU,OAAO,OAAU;AAAA,MAC5C;AAAA,IACF;AAEA,UAAM,SAAS,oBAAoB,KAAK;AAExC,WAAO,MAAM,EAAE,QAAQ;AAAA,MACrB,OAAO;AAAA,QACL,EAAE,IAAI,GAAG,MAAM,QAAQ;AAAA,QACvB,EAAE,IAAI,GAAG,MAAM,SAAS;AAAA,MAC1B;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AAED,KAAG,2CAA2C,MAAM;AAClD,UAAM,QAAQ;AAAA,MACZ,MAAM;AAAA,MACN,OAAO;AAAA,MACP,OAAO;AAAA,MACP,SAAS;AAAA,MACT,YAAY;AAAA,IACd;AAEA,UAAM,SAAS,oBAAoB,KAAK;AAExC,WAAO,MAAM,EAAE,QAAQ;AAAA,MACrB,MAAM;AAAA,MACN,OAAO;AAAA,MACP,OAAO;AAAA,MACP,SAAS;AAAA,IACX,CAAC;AAAA,EACH,CAAC;AACH,CAAC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { isJsonString, json, parseJsonOrYaml, transformToJson, yaml } from "./parse.js";
|
|
3
|
-
describe("Handles yaml and json parsing", () => {
|
|
4
|
-
it("Parses basic yaml", () => {
|
|
5
|
-
expect(yaml.parse("openapi: 3.0.0")).toEqual({
|
|
6
|
-
openapi: "3.0.0"
|
|
7
|
-
});
|
|
8
|
-
expect(json.parse('{ "openapi": "3.0.0" }')).toEqual({
|
|
9
|
-
openapi: "3.0.0"
|
|
10
|
-
});
|
|
11
|
-
});
|
|
12
|
-
it("Fails if any type except an object is not returned", () => {
|
|
13
|
-
expect(() => yaml.parse("10")).toThrowError();
|
|
14
|
-
expect(() => json.parse("10")).toThrowError();
|
|
15
|
-
});
|
|
16
|
-
it("transforms Yaml to JSON", () => {
|
|
17
|
-
expect(transformToJson("openapi: 3.0.0")).toMatchObject(JSON.stringify({ openapi: "3.0.0" }));
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
describe("isJsonString", () => {
|
|
21
|
-
it("keeps a path as is", async () => {
|
|
22
|
-
expect(isJsonString("foobar")).toBe(false);
|
|
23
|
-
});
|
|
24
|
-
it("removes slash", async () => {
|
|
25
|
-
expect(isJsonString('{ "foo": "bar" }')).toBe(true);
|
|
26
|
-
});
|
|
27
|
-
it("trims whitespace", async () => {
|
|
28
|
-
expect(isJsonString({ foo: "bar" })).toBe(false);
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
describe("parseJsonOrYaml", () => {
|
|
32
|
-
it("Handles json", () => {
|
|
33
|
-
expect(parseJsonOrYaml('{ "a": 10 }')).toEqual({ a: 10 });
|
|
34
|
-
});
|
|
35
|
-
it("Handles YAML", () => {
|
|
36
|
-
expect(parseJsonOrYaml("a: 10")).toEqual({ a: 10 });
|
|
37
|
-
});
|
|
38
|
-
it("Throws for invalid json or yaml", () => {
|
|
39
|
-
expect(() => parseJsonOrYaml("asdasdad: 0--- \n--")).toThrowError();
|
|
40
|
-
});
|
|
41
|
-
it("Throws if an object is not returned", () => {
|
|
42
|
-
expect(() => parseJsonOrYaml("asda")).toThrowError();
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
//# sourceMappingURL=parse.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/helpers/parse.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { isJsonString, json, parseJsonOrYaml, transformToJson, yaml } from './parse'\n\ndescribe('Handles yaml and json parsing', () => {\n it('Parses basic yaml', () => {\n expect(yaml.parse('openapi: 3.0.0')).toEqual({\n openapi: '3.0.0',\n })\n\n expect(json.parse('{ \"openapi\": \"3.0.0\" }')).toEqual({\n openapi: '3.0.0',\n })\n })\n\n it('Fails if any type except an object is not returned', () => {\n expect(() => yaml.parse('10')).toThrowError()\n expect(() => json.parse('10')).toThrowError()\n })\n\n it('transforms Yaml to JSON', () => {\n expect(transformToJson('openapi: 3.0.0')).toMatchObject(JSON.stringify({ openapi: '3.0.0' }))\n })\n})\n\ndescribe('isJsonString', () => {\n it('keeps a path as is', async () => {\n expect(isJsonString('foobar')).toBe(false)\n })\n\n it('removes slash', async () => {\n expect(isJsonString('{ \"foo\": \"bar\" }')).toBe(true)\n })\n\n it('trims whitespace', async () => {\n expect(isJsonString({ foo: 'bar' })).toBe(false)\n })\n})\n\ndescribe('parseJsonOrYaml', () => {\n it('Handles json', () => {\n expect(parseJsonOrYaml('{ \"a\": 10 }')).toEqual({ a: 10 })\n })\n\n it('Handles YAML', () => {\n expect(parseJsonOrYaml('a: 10')).toEqual({ a: 10 })\n })\n\n it('Throws for invalid json or yaml', () => {\n expect(() => parseJsonOrYaml('asdasdad: 0--- \\n--')).toThrowError()\n })\n\n it('Throws if an object is not returned', () => {\n expect(() => parseJsonOrYaml('asda')).toThrowError()\n })\n})\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,cAAc,MAAM,iBAAiB,iBAAiB,YAAY;AAE3E,SAAS,iCAAiC,MAAM;AAC9C,KAAG,qBAAqB,MAAM;AAC5B,WAAO,KAAK,MAAM,gBAAgB,CAAC,EAAE,QAAQ;AAAA,MAC3C,SAAS;AAAA,IACX,CAAC;AAED,WAAO,KAAK,MAAM,wBAAwB,CAAC,EAAE,QAAQ;AAAA,MACnD,SAAS;AAAA,IACX,CAAC;AAAA,EACH,CAAC;AAED,KAAG,sDAAsD,MAAM;AAC7D,WAAO,MAAM,KAAK,MAAM,IAAI,CAAC,EAAE,aAAa;AAC5C,WAAO,MAAM,KAAK,MAAM,IAAI,CAAC,EAAE,aAAa;AAAA,EAC9C,CAAC;AAED,KAAG,2BAA2B,MAAM;AAClC,WAAO,gBAAgB,gBAAgB,CAAC,EAAE,cAAc,KAAK,UAAU,EAAE,SAAS,QAAQ,CAAC,CAAC;AAAA,EAC9F,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB,MAAM;AAC7B,KAAG,sBAAsB,YAAY;AACnC,WAAO,aAAa,QAAQ,CAAC,EAAE,KAAK,KAAK;AAAA,EAC3C,CAAC;AAED,KAAG,iBAAiB,YAAY;AAC9B,WAAO,aAAa,kBAAkB,CAAC,EAAE,KAAK,IAAI;AAAA,EACpD,CAAC;AAED,KAAG,oBAAoB,YAAY;AACjC,WAAO,aAAa,EAAE,KAAK,MAAM,CAAC,CAAC,EAAE,KAAK,KAAK;AAAA,EACjD,CAAC;AACH,CAAC;AAED,SAAS,mBAAmB,MAAM;AAChC,KAAG,gBAAgB,MAAM;AACvB,WAAO,gBAAgB,aAAa,CAAC,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAC;AAAA,EAC1D,CAAC;AAED,KAAG,gBAAgB,MAAM;AACvB,WAAO,gBAAgB,OAAO,CAAC,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAC;AAAA,EACpD,CAAC;AAED,KAAG,mCAAmC,MAAM;AAC1C,WAAO,MAAM,gBAAgB,sBAAsB,CAAC,EAAE,aAAa;AAAA,EACrE,CAAC;AAED,KAAG,uCAAuC,MAAM;AAC9C,WAAO,MAAM,gBAAgB,MAAM,CAAC,EAAE,aAAa;AAAA,EACrD,CAAC;AACH,CAAC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { prettyPrintJson } from "./pretty-print-json.js";
|
|
3
|
-
describe("prettyPrintJson", () => {
|
|
4
|
-
it("makes JSON strings beautiful", async () => {
|
|
5
|
-
expect(prettyPrintJson('{ "foo": "bar" }')).toMatch(`{
|
|
6
|
-
"foo": "bar"
|
|
7
|
-
}`);
|
|
8
|
-
});
|
|
9
|
-
it("makes JS objects beautiful", async () => {
|
|
10
|
-
expect(prettyPrintJson({ foo: "bar" })).toMatch(`{
|
|
11
|
-
"foo": "bar"
|
|
12
|
-
}`);
|
|
13
|
-
});
|
|
14
|
-
it("doesn\u2019t touch regular strings", async () => {
|
|
15
|
-
expect(prettyPrintJson("foo")).toBe("foo");
|
|
16
|
-
});
|
|
17
|
-
it("transforms numbers", async () => {
|
|
18
|
-
expect(prettyPrintJson(123)).toBe("123");
|
|
19
|
-
});
|
|
20
|
-
it("deals with circular references", async () => {
|
|
21
|
-
const foo = { foo: "bar" };
|
|
22
|
-
foo.foo = foo;
|
|
23
|
-
expect(prettyPrintJson(foo)).toMatch(`{
|
|
24
|
-
"foo": "[Circular]"
|
|
25
|
-
}`);
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
//# sourceMappingURL=pretty-print-json.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/helpers/pretty-print-json.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { prettyPrintJson } from './pretty-print-json'\n\ndescribe('prettyPrintJson', () => {\n it('makes JSON strings beautiful', async () => {\n expect(prettyPrintJson('{ \"foo\": \"bar\" }')).toMatch(`{\\n \"foo\": \"bar\"\\n}`)\n })\n\n it('makes JS objects beautiful', async () => {\n expect(prettyPrintJson({ foo: 'bar' })).toMatch(`{\\n \"foo\": \"bar\"\\n}`)\n })\n\n it('doesn\u2019t touch regular strings', async () => {\n expect(prettyPrintJson('foo')).toBe('foo')\n })\n\n it('transforms numbers', async () => {\n expect(prettyPrintJson(123)).toBe('123')\n })\n\n it('deals with circular references', async () => {\n const foo: Record<string, any> = { foo: 'bar' }\n\n // Add a circular reference\n foo.foo = foo\n\n expect(prettyPrintJson(foo)).toMatch(`{\\n \"foo\": \"[Circular]\"\\n}`)\n })\n})\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,uBAAuB;AAEhC,SAAS,mBAAmB,MAAM;AAChC,KAAG,gCAAgC,YAAY;AAC7C,WAAO,gBAAgB,kBAAkB,CAAC,EAAE,QAAQ;AAAA;AAAA,EAAsB;AAAA,EAC5E,CAAC;AAED,KAAG,8BAA8B,YAAY;AAC3C,WAAO,gBAAgB,EAAE,KAAK,MAAM,CAAC,CAAC,EAAE,QAAQ;AAAA;AAAA,EAAsB;AAAA,EACxE,CAAC;AAED,KAAG,sCAAiC,YAAY;AAC9C,WAAO,gBAAgB,KAAK,CAAC,EAAE,KAAK,KAAK;AAAA,EAC3C,CAAC;AAED,KAAG,sBAAsB,YAAY;AACnC,WAAO,gBAAgB,GAAG,CAAC,EAAE,KAAK,KAAK;AAAA,EACzC,CAAC;AAED,KAAG,kCAAkC,YAAY;AAC/C,UAAM,MAA2B,EAAE,KAAK,MAAM;AAG9C,QAAI,MAAM;AAEV,WAAO,gBAAgB,GAAG,CAAC,EAAE,QAAQ;AAAA;AAAA,EAA6B;AAAA,EACpE,CAAC;AACH,CAAC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { isRelativePath, redirectToProxy } from "./redirect-to-proxy.js";
|
|
3
|
-
describe("redirectToProxy", () => {
|
|
4
|
-
it("rewrites URLs", () => {
|
|
5
|
-
expect(redirectToProxy("https://proxy.scalar.com", "https://example.com")).toBe(
|
|
6
|
-
"https://proxy.scalar.com/?scalar_url=https%3A%2F%2Fexample.com"
|
|
7
|
-
);
|
|
8
|
-
});
|
|
9
|
-
it("keeps query parameters", () => {
|
|
10
|
-
expect(redirectToProxy("https://proxy.scalar.com?foo=bar", "https://example.com")).toBe(
|
|
11
|
-
"https://proxy.scalar.com/?foo=bar&scalar_url=https%3A%2F%2Fexample.com"
|
|
12
|
-
);
|
|
13
|
-
});
|
|
14
|
-
it("uses the proxy when the proxyUrl is relative", () => {
|
|
15
|
-
expect(redirectToProxy("/proxy", "http://localhost:3000/api")).toBe(
|
|
16
|
-
"/proxy?scalar_url=http%3A%2F%2Flocalhost%3A3000%2Fapi"
|
|
17
|
-
);
|
|
18
|
-
});
|
|
19
|
-
it("skips the proxy if no proxy url is passed", () => {
|
|
20
|
-
expect(redirectToProxy("", "https://example.com")).toBe("https://example.com");
|
|
21
|
-
});
|
|
22
|
-
it("skips the proxy for relative URLs starting with a slash", () => {
|
|
23
|
-
expect(redirectToProxy("https://proxy.scalar.com", "/api")).toBe("/api");
|
|
24
|
-
});
|
|
25
|
-
it("skips the proxy for relative URLs not starting with a slash", () => {
|
|
26
|
-
expect(redirectToProxy("https://proxy.scalar.com", "api")).toBe("api");
|
|
27
|
-
});
|
|
28
|
-
it("skips the proxy for relative URLs not starting with a slash, but containing a dot", () => {
|
|
29
|
-
expect(redirectToProxy("https://proxy.scalar.com", "openapi.json")).toBe("openapi.json");
|
|
30
|
-
});
|
|
31
|
-
it("uses the proxy when it\u2019s local", () => {
|
|
32
|
-
expect(redirectToProxy("http://localhost:3000/proxy", "http://localhost:3000/api")).toBe(
|
|
33
|
-
"http://localhost:3000/proxy?scalar_url=http%3A%2F%2Flocalhost%3A3000%2Fapi"
|
|
34
|
-
);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
describe("isRelativePath", () => {
|
|
38
|
-
it("returns true for relative paths starting with a slash", () => {
|
|
39
|
-
expect(isRelativePath("/api")).toBe(true);
|
|
40
|
-
});
|
|
41
|
-
it("returns true for relative paths without a slash", () => {
|
|
42
|
-
expect(isRelativePath("api")).toBe(true);
|
|
43
|
-
});
|
|
44
|
-
it("returns false for absolute URLs with http", () => {
|
|
45
|
-
expect(isRelativePath("http://example.com")).toBe(false);
|
|
46
|
-
});
|
|
47
|
-
it("returns false for absolute URLs with https", () => {
|
|
48
|
-
expect(isRelativePath("https://example.com")).toBe(false);
|
|
49
|
-
});
|
|
50
|
-
it("returns false for domain-like URLs without protocol", () => {
|
|
51
|
-
expect(isRelativePath("example.com/api")).toBe(false);
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
//# sourceMappingURL=redirect-to-proxy.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/helpers/redirect-to-proxy.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { isRelativePath, redirectToProxy } from './redirect-to-proxy'\n\ndescribe('redirectToProxy', () => {\n it('rewrites URLs', () => {\n expect(redirectToProxy('https://proxy.scalar.com', 'https://example.com')).toBe(\n 'https://proxy.scalar.com/?scalar_url=https%3A%2F%2Fexample.com',\n )\n })\n\n it('keeps query parameters', () => {\n expect(redirectToProxy('https://proxy.scalar.com?foo=bar', 'https://example.com')).toBe(\n 'https://proxy.scalar.com/?foo=bar&scalar_url=https%3A%2F%2Fexample.com',\n )\n })\n\n it('uses the proxy when the proxyUrl is relative', () => {\n expect(redirectToProxy('/proxy', 'http://localhost:3000/api')).toBe(\n '/proxy?scalar_url=http%3A%2F%2Flocalhost%3A3000%2Fapi',\n )\n })\n\n it('skips the proxy if no proxy url is passed', () => {\n expect(redirectToProxy('', 'https://example.com')).toBe('https://example.com')\n })\n\n it('skips the proxy for relative URLs starting with a slash', () => {\n expect(redirectToProxy('https://proxy.scalar.com', '/api')).toBe('/api')\n })\n\n it('skips the proxy for relative URLs not starting with a slash', () => {\n expect(redirectToProxy('https://proxy.scalar.com', 'api')).toBe('api')\n })\n\n it('skips the proxy for relative URLs not starting with a slash, but containing a dot', () => {\n expect(redirectToProxy('https://proxy.scalar.com', 'openapi.json')).toBe('openapi.json')\n })\n\n it('uses the proxy when it\u2019s local', () => {\n expect(redirectToProxy('http://localhost:3000/proxy', 'http://localhost:3000/api')).toBe(\n 'http://localhost:3000/proxy?scalar_url=http%3A%2F%2Flocalhost%3A3000%2Fapi',\n )\n })\n})\n\ndescribe('isRelativePath', () => {\n it('returns true for relative paths starting with a slash', () => {\n expect(isRelativePath('/api')).toBe(true)\n })\n\n it('returns true for relative paths without a slash', () => {\n expect(isRelativePath('api')).toBe(true)\n })\n\n it('returns false for absolute URLs with http', () => {\n expect(isRelativePath('http://example.com')).toBe(false)\n })\n\n it('returns false for absolute URLs with https', () => {\n expect(isRelativePath('https://example.com')).toBe(false)\n })\n\n it('returns false for domain-like URLs without protocol', () => {\n expect(isRelativePath('example.com/api')).toBe(false)\n })\n})\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,gBAAgB,uBAAuB;AAEhD,SAAS,mBAAmB,MAAM;AAChC,KAAG,iBAAiB,MAAM;AACxB,WAAO,gBAAgB,4BAA4B,qBAAqB,CAAC,EAAE;AAAA,MACzE;AAAA,IACF;AAAA,EACF,CAAC;AAED,KAAG,0BAA0B,MAAM;AACjC,WAAO,gBAAgB,oCAAoC,qBAAqB,CAAC,EAAE;AAAA,MACjF;AAAA,IACF;AAAA,EACF,CAAC;AAED,KAAG,gDAAgD,MAAM;AACvD,WAAO,gBAAgB,UAAU,2BAA2B,CAAC,EAAE;AAAA,MAC7D;AAAA,IACF;AAAA,EACF,CAAC;AAED,KAAG,6CAA6C,MAAM;AACpD,WAAO,gBAAgB,IAAI,qBAAqB,CAAC,EAAE,KAAK,qBAAqB;AAAA,EAC/E,CAAC;AAED,KAAG,2DAA2D,MAAM;AAClE,WAAO,gBAAgB,4BAA4B,MAAM,CAAC,EAAE,KAAK,MAAM;AAAA,EACzE,CAAC;AAED,KAAG,+DAA+D,MAAM;AACtE,WAAO,gBAAgB,4BAA4B,KAAK,CAAC,EAAE,KAAK,KAAK;AAAA,EACvE,CAAC;AAED,KAAG,qFAAqF,MAAM;AAC5F,WAAO,gBAAgB,4BAA4B,cAAc,CAAC,EAAE,KAAK,cAAc;AAAA,EACzF,CAAC;AAED,KAAG,uCAAkC,MAAM;AACzC,WAAO,gBAAgB,+BAA+B,2BAA2B,CAAC,EAAE;AAAA,MAClF;AAAA,IACF;AAAA,EACF,CAAC;AACH,CAAC;AAED,SAAS,kBAAkB,MAAM;AAC/B,KAAG,yDAAyD,MAAM;AAChE,WAAO,eAAe,MAAM,CAAC,EAAE,KAAK,IAAI;AAAA,EAC1C,CAAC;AAED,KAAG,mDAAmD,MAAM;AAC1D,WAAO,eAAe,KAAK,CAAC,EAAE,KAAK,IAAI;AAAA,EACzC,CAAC;AAED,KAAG,6CAA6C,MAAM;AACpD,WAAO,eAAe,oBAAoB,CAAC,EAAE,KAAK,KAAK;AAAA,EACzD,CAAC;AAED,KAAG,8CAA8C,MAAM;AACrD,WAAO,eAAe,qBAAqB,CAAC,EAAE,KAAK,KAAK;AAAA,EAC1D,CAAC;AAED,KAAG,uDAAuD,MAAM;AAC9D,WAAO,eAAe,iBAAiB,CAAC,EAAE,KAAK,KAAK;AAAA,EACtD,CAAC;AACH,CAAC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { REGEX } from "./regex-helpers.js";
|
|
3
|
-
describe("protocolRegex", () => {
|
|
4
|
-
it("allows http://", () => {
|
|
5
|
-
const text = "http://example.com";
|
|
6
|
-
expect(text.match(REGEX.PROTOCOL)).toBeTruthy();
|
|
7
|
-
});
|
|
8
|
-
it("allows https://", () => {
|
|
9
|
-
const text = "https://example.com";
|
|
10
|
-
expect(text.match(REGEX.PROTOCOL)).toBeTruthy();
|
|
11
|
-
});
|
|
12
|
-
it("allows file://", () => {
|
|
13
|
-
const text = "file://example.com";
|
|
14
|
-
expect(text.match(REGEX.PROTOCOL)).toBeTruthy();
|
|
15
|
-
});
|
|
16
|
-
it("allows ftp://", () => {
|
|
17
|
-
const text = "ftp://example.com";
|
|
18
|
-
expect(text.match(REGEX.PROTOCOL)).toBeTruthy();
|
|
19
|
-
});
|
|
20
|
-
it("allows mailto://", () => {
|
|
21
|
-
const text = "mailto://example.com";
|
|
22
|
-
expect(text.match(REGEX.PROTOCOL)).toBeTruthy();
|
|
23
|
-
});
|
|
24
|
-
it("does not allow variables before ://", () => {
|
|
25
|
-
const text = "{protocol}://example.com";
|
|
26
|
-
expect(text.match(REGEX.PROTOCOL)).toBeNull();
|
|
27
|
-
});
|
|
28
|
-
it("does not allow no protocol with a variable", () => {
|
|
29
|
-
const text = "{base}/api";
|
|
30
|
-
expect(text.match(REGEX.PROTOCOL)).toBeNull();
|
|
31
|
-
});
|
|
32
|
-
it("does not allow no protocol with no variables", () => {
|
|
33
|
-
const text = "example.com";
|
|
34
|
-
expect(text.match(REGEX.PROTOCOL)).toBeNull();
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
describe("multipleSlashesRegex", () => {
|
|
38
|
-
it("matches multiple slashes", () => {
|
|
39
|
-
const text = "http://example.com//api".replace(REGEX.MULTIPLE_SLASHES, "/");
|
|
40
|
-
expect(text).toBe("http://example.com/api");
|
|
41
|
-
});
|
|
42
|
-
it("matches multiple slashes in the path", () => {
|
|
43
|
-
const text = "http://example.com/api//users////{id}".replace(REGEX.MULTIPLE_SLASHES, "/");
|
|
44
|
-
expect(text).toBe("http://example.com/api/users/{id}");
|
|
45
|
-
});
|
|
46
|
-
it("does not match single slash or the scheme", () => {
|
|
47
|
-
const text = "http://example.com/api/users/{id}";
|
|
48
|
-
expect(text.match(REGEX.MULTIPLE_SLASHES)).toBeNull();
|
|
49
|
-
});
|
|
50
|
-
it("does not do anything to the query params", () => {
|
|
51
|
-
const text = "http://example.com/api/users/{id}?query=param";
|
|
52
|
-
expect(text.replace(REGEX.MULTIPLE_SLASHES, "/")).toBe("http://example.com/api/users/{id}?query=param");
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
describe("variableRegex", () => {
|
|
56
|
-
it("matches variables with double curly braces", () => {
|
|
57
|
-
const text = "{{example.com}}";
|
|
58
|
-
const matches = [...text.matchAll(REGEX.VARIABLES)];
|
|
59
|
-
expect(matches.length).toBe(1);
|
|
60
|
-
expect(matches[0][1]).toBe("example.com");
|
|
61
|
-
});
|
|
62
|
-
it("matches variables with nested curly braces", () => {
|
|
63
|
-
const text = "{{example.com:{port}}}";
|
|
64
|
-
const matches = [...text.matchAll(REGEX.VARIABLES)];
|
|
65
|
-
expect(matches.length).toBe(1);
|
|
66
|
-
expect(matches[0][1]).toBe("example.com:{port}");
|
|
67
|
-
});
|
|
68
|
-
it("matches multiple variables", () => {
|
|
69
|
-
const text = "{{{host}.example.com:{port}}}";
|
|
70
|
-
const matches = [...text.matchAll(REGEX.VARIABLES)];
|
|
71
|
-
expect(matches.length).toBe(1);
|
|
72
|
-
expect(matches[0][1]).toBe("{host}.example.com:{port}");
|
|
73
|
-
});
|
|
74
|
-
it("does not match single curly braces", () => {
|
|
75
|
-
const text = "{example.com}";
|
|
76
|
-
const matches = [...text.matchAll(REGEX.VARIABLES)];
|
|
77
|
-
expect(matches.length).toBe(0);
|
|
78
|
-
});
|
|
79
|
-
it("does not match unbalanced curly braces", () => {
|
|
80
|
-
const text = "{{example.com}";
|
|
81
|
-
const matches = [...text.matchAll(REGEX.VARIABLES)];
|
|
82
|
-
expect(matches.length).toBe(0);
|
|
83
|
-
});
|
|
84
|
-
it("matches variables with whitespace", () => {
|
|
85
|
-
const text = "{{ example.com }}";
|
|
86
|
-
const matches = [...text.matchAll(REGEX.VARIABLES)];
|
|
87
|
-
expect(matches.length).toBe(1);
|
|
88
|
-
expect(matches[0][1]).toBe(" example.com ");
|
|
89
|
-
});
|
|
90
|
-
it("matches variables in longer text", () => {
|
|
91
|
-
const text = "prefix {{variable}} suffix";
|
|
92
|
-
const matches = [...text.matchAll(REGEX.VARIABLES)];
|
|
93
|
-
expect(matches.length).toBe(1);
|
|
94
|
-
expect(matches[0][1]).toBe("variable");
|
|
95
|
-
});
|
|
96
|
-
it("matches multiple separate variables", () => {
|
|
97
|
-
const text = "{{first}} middle {{second}}";
|
|
98
|
-
const matches = [...text.matchAll(REGEX.VARIABLES)];
|
|
99
|
-
expect(matches.length).toBe(2);
|
|
100
|
-
expect(matches[0][1]).toBe("first");
|
|
101
|
-
expect(matches[1][1]).toBe("second");
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
describe("pathRegex", () => {
|
|
105
|
-
it("matches path parameters", () => {
|
|
106
|
-
const text = "/users/{id}";
|
|
107
|
-
const matches = [...text.matchAll(REGEX.PATH)];
|
|
108
|
-
expect(matches.length).toBe(1);
|
|
109
|
-
expect(matches[0][1]).toBe("id");
|
|
110
|
-
});
|
|
111
|
-
it("matches multiple path parameters", () => {
|
|
112
|
-
const text = "/users/{userId}/posts/{postId}";
|
|
113
|
-
const matches = [...text.matchAll(REGEX.PATH)];
|
|
114
|
-
expect(matches.length).toBe(2);
|
|
115
|
-
expect(matches[0][1]).toBe("userId");
|
|
116
|
-
expect(matches[1][1]).toBe("postId");
|
|
117
|
-
});
|
|
118
|
-
it("does not match double curly braces", () => {
|
|
119
|
-
const text = "/users/{{id}}";
|
|
120
|
-
const matches = [...text.matchAll(REGEX.PATH)];
|
|
121
|
-
expect(matches.length).toBe(0);
|
|
122
|
-
});
|
|
123
|
-
it("matches path parameters with dots", () => {
|
|
124
|
-
const text = "/api/{version}/users";
|
|
125
|
-
const matches = [...text.matchAll(REGEX.PATH)];
|
|
126
|
-
expect(matches.length).toBe(1);
|
|
127
|
-
expect(matches[0][1]).toBe("version");
|
|
128
|
-
});
|
|
129
|
-
it("matches path parameters with hyphens and underscores", () => {
|
|
130
|
-
const text = "/users/{user-id}/posts/{post_id}";
|
|
131
|
-
const matches = [...text.matchAll(REGEX.PATH)];
|
|
132
|
-
expect(matches.length).toBe(2);
|
|
133
|
-
expect(matches[0][1]).toBe("user-id");
|
|
134
|
-
expect(matches[1][1]).toBe("post_id");
|
|
135
|
-
});
|
|
136
|
-
it("does not match nested curly braces", () => {
|
|
137
|
-
const text = "/users/{outer{inner}}";
|
|
138
|
-
const matches = [...text.matchAll(REGEX.PATH)];
|
|
139
|
-
expect(matches.length).toBe(0);
|
|
140
|
-
});
|
|
141
|
-
it("matches path parameters at start of string", () => {
|
|
142
|
-
const text = "{version}/api";
|
|
143
|
-
const matches = [...text.matchAll(REGEX.PATH)];
|
|
144
|
-
expect(matches.length).toBe(1);
|
|
145
|
-
expect(matches[0][1]).toBe("version");
|
|
146
|
-
});
|
|
147
|
-
it("matches path parameters at end of string", () => {
|
|
148
|
-
const text = "/api/{version}";
|
|
149
|
-
const matches = [...text.matchAll(REGEX.PATH)];
|
|
150
|
-
expect(matches.length).toBe(1);
|
|
151
|
-
expect(matches[0][1]).toBe("version");
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
//# sourceMappingURL=regex-helpers.test.js.map
|