Skip to content

Conversation

@pataraco
Copy link

@pataraco pataraco commented Jul 19, 2025

When specifying an index to the split() function, the entire list of split items would be returned.

Example/snippet serverless.yaml

custom:
  moniker: "ABCD-DEV-USWEST2"
  moniker_split: ${split(${self:custom.adsk_moniker,'-'})}
  moniker_name: ${split(${self:custom.adsk_moniker,'-',0})}
  moniker_env: ${split(${self:custom.adsk_moniker,'-',1})}
  moniker_region: ${split(${self:custom.adsk_moniker,'-',2})}

Bug:

$ npx sls print -s dev --path custom
moniker: ABCD-DEV-USWEST2
moniker_split:
  - ABCD
  - DEV
  - USWEST2
moniker_name:
  - ABCD
  - DEV
  - USWEST2
moniker_env:
  - ABCD
  - DEV
  - USWEST2
moniker_region:
  - ABCD
  - DEV
  - USWEST2

Fix:

$ npx sls print -s dev --path custom
moniker: ABCD-DEV-USWEST2
moniker_split:
  - ABCD
  - DEV
  - USWEST2
moniker_name: ABCD
moniker_env: DEV
moniker_region: USWEST2

Fixes #12

@pataraco
Copy link
Author

Hey @icarus-sullivan , @ymulenll and/or @peter604 !

Any hopes of getting this PR approved/merged and the npm package updated?
I didn't realize that this plugin hasn't really been maintained in a while before I started using it in our org.
And now it would be great to have this fix! 🙏

Also, if you're open to it, I'll add a replace() function 😁

Thanks guys!

@pataraco pataraco changed the title Fix: split indexing Fix: split indexing [Fixes #12] Jul 22, 2025
@pataraco
Copy link
Author

Hello Hey @icarus-sullivan , @ymulenll and/or @peter604 !

Have you had a chance to look at this?

Any hopes of approving/merging?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

It fails when I send index 0

1 participant