Skip to content

It fails when I send index 0 #12

@vjmartinez89

Description

@vjmartinez89

When I send 0 as the index parameter, it returns an array rather than a string. This is because the index parameter is null in the "split" method.

module.exports = ({ params }) => {
  const [value, delimiter, index] = params;
  return {
    value:
      typeof index === 'number'
        ? value.split(delimiter)[index]
        : value.split(delimiter),
  };
};

The configuration I'm using is:

provider:
  ...
  environment:
    ...
    VAR_ONE: ${split("var_one_value/var_two_value", '/', 1)}
    VAR_TWO:   ${split("var_one_value/var_two_value", '/', 0)}

When I access those two variables I receive:

VAR_ONE = var_one_value
VAR_TWO = var_one_value,var_two_value

Environment:

Plugin version: "serverless-plugin-utils": "^0.2.0",
Framework version: "serverless": "^3.27.0",

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions