j-d-carmichael / boats

Beautiful Open Api Template System
MIT License
57 stars 8 forks source link

fix: trim only replaces last occurence of trim #76

Closed acr-tom-bee closed 2 years ago

acr-tom-bee commented 2 years ago

:heavy_check_mark: Includes additions to the docs, found in the docs/readme file, as required - (Not required) :heavy_check_mark: Includes a new line in the changelog titling the change :heavy_check_mark: The new and changed code you have written is unit tested and passes the eslint :heavy_check_mark: The body of the text for this PR includes enough text for a reviewer to understand the context of the change

I'm working on a project which has entities called 'ModelCode', 'ModelRange', 'ModelCodeLabel' etc.

We found that the current implementation of trimming using string.replace(trim, '') was replacing the first instance of 'Model' that was found in the string.

This was causing odd errors and turning 'ModelCode' into 'CodeModel'.

This fix means that only the last instance of the trim string will be replaced from singular or plural schema models.

j-d-carmichael commented 2 years ago

@acr-tom-bee looks good! Thanks for the contribution :)

I've edited the PR to dev not main.

acr-tom-bee commented 2 years ago

@j-d-carmichael Thanks for the quick merge :) Sorry about the branch mix up. I wasn't sure whether fixes went straight into main or dev first. I'll pop any future ones onto dev.