Unverified Commit 2e02204d authored by Kiko Beats's avatar Kiko Beats Committed by GitHub
parent 976ccce5
......@@ -57,7 +57,7 @@
"@babel/plugin-proposal-object-rest-spread": "7.14.7",
"@babel/preset-flow": "7.14.5",
"@babel/preset-react": "7.14.5",
"@edge-runtime/jest-environment": "1.1.0-beta.31",
"@edge-runtime/jest-environment": "1.1.0-beta.33",
"@fullhuman/postcss-purgecss": "1.3.0",
"@mdx-js/loader": "0.18.0",
"@next/bundle-analyzer": "workspace:*",
......
declare const AbortControllerConstructor: AbortController
declare const AbortControllerConstructor: typeof AbortController
declare const DOMExceptionConstructor: typeof DOMException
declare var AbortSignal: {
prototype: typeof AbortSignal
......@@ -9,4 +11,4 @@ declare var AbortSignal: {
abort(reason?: string): AbortSignal
}
export { AbortControllerConstructor as AbortController, AbortSignal };
export { AbortControllerConstructor as AbortController, AbortSignal, DOMExceptionConstructor as DOMException };
declare function createCaches(): {
cacheStorage: () => CacheStorage
Cache: typeof Cache
CacheStorage: typeof CacheStorage
}
declare function createCaches():
| undefined
| {
cacheStorage: () => CacheStorage
Cache: typeof Cache
CacheStorage: typeof CacheStorage
}
declare const caches: CacheStorage
......
This source diff could not be displayed because it is too large. You can view the blob instead.
{"name":"@edge-runtime/primitives","version":"1.1.0-beta.31","main":"./index.js","license":"MPLv2"}
{"name":"@edge-runtime/primitives","version":"1.1.0-beta.34","main":"./index.js","license":"MPLv2"}
......@@ -48,8 +48,8 @@ interface URLPatternComponentResult {
};
}
declare const URLPatternConstructor: typeof URLPattern
declare const URLConstructor: typeof URL
declare const URLSearchParamsConstructor: typeof URLSearchParams
declare const _URL: typeof URL
declare const _URLSearchParams: typeof URLSearchParams
declare class _URLPattern extends URLPattern {}
export { URLConstructor as URL, URLPatternConstructor as URLPattern, URLSearchParamsConstructor as URLSearchParams };
export { _URL as URL, _URLPattern as URLPattern, _URLSearchParams as URLSearchParams };
......@@ -3372,10 +3372,10 @@ module.exports = __toCommonJS(url_exports);
init_define_process();
var import_whatwg_url = __toESM(require_whatwg_url());
// ../../node_modules/.pnpm/urlpattern-polyfill@5.0.6/node_modules/urlpattern-polyfill/index.js
// ../../node_modules/.pnpm/urlpattern-polyfill@5.0.9/node_modules/urlpattern-polyfill/index.js
init_define_process();
// ../../node_modules/.pnpm/urlpattern-polyfill@5.0.6/node_modules/urlpattern-polyfill/dist/urlpattern.js
// ../../node_modules/.pnpm/urlpattern-polyfill@5.0.9/node_modules/urlpattern-polyfill/dist/urlpattern.js
init_define_process();
var regexIdentifierStart = /[$_\p{ID_Start}]/u;
var regexIdentifierPart = /[$_\u200C\u200D\p{ID_Continue}]/u;
......@@ -3489,10 +3489,9 @@ function lexer(str, lenient = false) {
}
__name(lexer, "lexer");
function parse(str, options = {}) {
var _a;
const tokens = lexer(str);
const { prefixes = "./" } = options;
const defaultPattern = `[^${escapeString((_a = options.delimiter) != null ? _a : "/#?")}]+?`;
const defaultPattern = `[^${escapeString(options.delimiter === void 0 ? "/#?" : options.delimiter)}]+?`;
const result = [];
let key = 0;
let i = 0;
......@@ -3641,15 +3640,14 @@ function stringToRegexp(path, keys, options) {
}
__name(stringToRegexp, "stringToRegexp");
function tokensToRegexp(tokens, keys, options = {}) {
var _a, _b;
const {
strict = false,
start = true,
end = true,
encode = /* @__PURE__ */ __name((x) => x, "encode")
} = options;
const endsWith = `[${escapeString((_a = options.endsWith) != null ? _a : "")}]|$`;
const delimiter = `[${escapeString((_b = options.delimiter) != null ? _b : "/#?")}]`;
const endsWith = `[${escapeString(options.endsWith === void 0 ? "" : options.endsWith)}]|$`;
const delimiter = `[${escapeString(options.delimiter === void 0 ? "/#?" : options.delimiter)}]`;
let route = start ? "^" : "";
for (const token of tokens) {
if (typeof token === "string") {
......@@ -4334,9 +4332,8 @@ function escapeRegexpString(value) {
}
__name(escapeRegexpString, "escapeRegexpString");
function tokensToPattern(tokens, options) {
var _a;
const wildcardPattern = ".*";
const segmentWildcardPattern = `[^${escapeRegexpString((_a = options.delimiter) != null ? _a : "/#?")}]+?`;
const segmentWildcardPattern = `[^${escapeRegexpString(options.delimiter === void 0 ? "/#?" : options.delimiter)}]+?`;
const regexIdentifierPart2 = /[$_\u200C\u200D\p{ID_Continue}]/u;
let result = "";
for (let i = 0; i < tokens.length; ++i) {
......@@ -4617,7 +4614,7 @@ var URLPattern = /* @__PURE__ */ __name(class {
}
}, "URLPattern");
// ../../node_modules/.pnpm/urlpattern-polyfill@5.0.6/node_modules/urlpattern-polyfill/index.js
// ../../node_modules/.pnpm/urlpattern-polyfill@5.0.9/node_modules/urlpattern-polyfill/index.js
if (!globalThis.URLPattern) {
globalThis.URLPattern = URLPattern;
}
......
......@@ -115,7 +115,7 @@
"@babel/runtime": "7.15.4",
"@babel/traverse": "7.18.0",
"@babel/types": "7.18.0",
"@edge-runtime/primitives": "1.1.0-beta.31",
"@edge-runtime/primitives": "1.1.0-beta.34",
"@hapi/accept": "5.0.2",
"@napi-rs/cli": "2.7.0",
"@napi-rs/triples": "1.1.0",
......@@ -193,7 +193,7 @@
"debug": "4.1.1",
"devalue": "2.0.1",
"domain-browser": "4.19.0",
"edge-runtime": "1.1.0-beta.31",
"edge-runtime": "1.1.0-beta.34",
"events": "3.3.0",
"find-cache-dir": "3.3.1",
"find-up": "4.1.0",
......
......@@ -3,11 +3,14 @@ import { PassThrough, Readable } from 'stream'
export function requestToBodyStream(
context: { ReadableStream: typeof ReadableStream },
KUint8Array: typeof Uint8Array,
stream: Readable
) {
return new context.ReadableStream({
start(controller) {
stream.on('data', (chunk) => controller.enqueue(chunk))
stream.on('data', (chunk) =>
controller.enqueue(new KUint8Array([...new Uint8Array(chunk)]))
)
stream.on('end', () => controller.close())
stream.on('error', (err) => controller.error(err))
},
......
......@@ -34,7 +34,7 @@ export async function fetchInlineAsset(options: {
if (fileIsReadable) {
const readStream = createReadStream(filePath)
return new options.context.Response(
requestToBodyStream(options.context, readStream)
requestToBodyStream(options.context, Uint8Array, readStream)
)
}
}
......@@ -92,11 +92,14 @@ export const run = withTaggedErrors(async (params) => {
? params.request.body?.cloneBodyStream()
: undefined
const KUint8Array = runtime.evaluate('Uint8Array')
try {
const result = await edgeFunction({
request: {
...params.request,
body: cloned && requestToBodyStream(runtime.context, cloned),
body:
cloned && requestToBodyStream(runtime.context, KUint8Array, cloned),
},
})
for (const headerName of FORBIDDEN_HEADERS) {
......
This diff is collapsed.
......@@ -440,7 +440,7 @@ describe('Middleware Runtime', () => {
const payload = readMiddlewareJSON(response)
expect('error' in payload).toBe(true)
expect(payload.error.name).toBe('AbortError')
expect(payload.error.message).toBe('The operation was aborted')
expect(payload.error.message).toBe('The operation was aborted.')
})
it(`should validate & parse request url from any route`, async () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment