@sinch/functions-runtime 0.3.5 → 0.3.7

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/dist/index.js CHANGED
@@ -983,7 +983,8 @@ function extractFunctionName(path5, body) {
983
983
  if (body?.event && isVoiceCallback(body.event)) {
984
984
  return body.event;
985
985
  }
986
- const segments = path5.split("/").filter((s) => s && s !== "*");
986
+ const pathname = path5.split("?")[0];
987
+ const segments = pathname.split("/").filter((s) => s && s !== "*");
987
988
  if (segments.length === 1 && isVoiceCallback(segments[0])) {
988
989
  return segments[0];
989
990
  }
@@ -1186,7 +1187,7 @@ function setupRequestHandler(app, options = {}) {
1186
1187
  res.type("image/svg+xml").send(svg);
1187
1188
  return;
1188
1189
  }
1189
- if (req.method === "GET" && req.path === "/" && landingPageEnabled) {
1190
+ if (req.method === "GET" && req.originalUrl === "/" && landingPageEnabled) {
1190
1191
  const acceptHeader = req.headers.accept || "";
1191
1192
  if (acceptHeader.includes("text/html")) {
1192
1193
  const html = getLandingPageHtml();
@@ -1194,7 +1195,7 @@ function setupRequestHandler(app, options = {}) {
1194
1195
  return;
1195
1196
  }
1196
1197
  }
1197
- if (req.method === "GET" && req.path === "/" && !landingPageEnabled) {
1198
+ if (req.method === "GET" && req.originalUrl === "/" && !landingPageEnabled) {
1198
1199
  const indexPath = nodePath.join(process.cwd(), "public", "index.html");
1199
1200
  if (nodeFs.existsSync(indexPath)) {
1200
1201
  res.type("html").sendFile(indexPath);
@@ -1202,7 +1203,7 @@ function setupRequestHandler(app, options = {}) {
1202
1203
  }
1203
1204
  }
1204
1205
  try {
1205
- const functionName = extractFunctionName(req.baseUrl, req.body);
1206
+ const functionName = extractFunctionName(req.originalUrl, req.body);
1206
1207
  logger(`[${(/* @__PURE__ */ new Date()).toISOString()}] ${req.method} ${req.path} -> ${functionName}`);
1207
1208
  onRequestStart({ functionName, req });
1208
1209
  const context = buildContext(req);
@@ -1261,7 +1262,7 @@ function setupRequestHandler(app, options = {}) {
1261
1262
  logger("Function execution error:", {
1262
1263
  error: error.message,
1263
1264
  stack: error.stack,
1264
- function: extractFunctionName(req.path, req.body)
1265
+ function: extractFunctionName(req.originalUrl, req.body)
1265
1266
  });
1266
1267
  res.status(500).json({
1267
1268
  error: "Internal server error",
@@ -1269,7 +1270,7 @@ function setupRequestHandler(app, options = {}) {
1269
1270
  ...process.env.NODE_ENV === "development" && { stack: error.stack }
1270
1271
  });
1271
1272
  onRequestEnd({
1272
- functionName: extractFunctionName(req.path, req.body),
1273
+ functionName: extractFunctionName(req.originalUrl, req.body),
1273
1274
  req,
1274
1275
  error,
1275
1276
  duration,