Skip to content

Commit

Permalink
Use constant for base url placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
dnalborczyk committed Jul 8, 2019
1 parent 181edbb commit c996a94
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/ApiGatewayWebSocket.js
Expand Up @@ -13,6 +13,11 @@ const { createUniqueId, parseQueryStringParameters } = require('./utils');
const authFunctionNameExtractor = require('./authFunctionNameExtractor');
const wsHelpers = require('./websocketHelpers');

// dummy placeholder url for the WHATWG URL constructor
// https://github.com/nodejs/node/issues/12682
// TODO move to common constants file
const BASE_URL_PLACEHOLDER = 'http://example';

module.exports = class ApiGatewayWebSocket {
constructor(serverless, options) {
this.serverless = serverless;
Expand Down Expand Up @@ -171,7 +176,7 @@ module.exports = class ApiGatewayWebSocket {
only: true,
initially: false,
connect: ({ ws, req }) => {
const { searchParams } = new URL(req.url, `ws://${req.headers.host}`);
const { searchParams } = new URL(req.url, BASE_URL_PLACEHOLDER);
const queryStringParameters = parseQueryStringParameters(
searchParams,
);
Expand Down

0 comments on commit c996a94

Please sign in to comment.