Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Fix bug trailing slash to the prefix #4

Merged
merged 1 commit into from
Apr 19, 2021
Merged

Fix bug trailing slash to the prefix #4

merged 1 commit into from
Apr 19, 2021

Conversation

fabhoarau
Copy link
Member

Closes #422

Parent issue
mockoon/mockoon#422

Closes #422

Technical implementation details

@fabhoarau fabhoarau requested a review from 255kb as a code owner April 18, 2021 20:48
@255kb 255kb merged commit d639c01 into main Apr 19, 2021
@255kb 255kb deleted the fix/api-endpoint branch April 19, 2021 07:19
let routePath = `/${
this.environment.endpointPrefix
}/${declaredRoute.endpoint.replace(/ /g, '%20')}`;
routePath = routePath.replace('//', '');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@255kb I think this should be

routePath = routePath.replace('//', '/')

Otherwise, double slashes get completely removed. Apart from that, I think this is not the best solution as it would not solve cases where there are tripple slashes and especially, it only replaces the first occurrence of a double slash and not all.

I suggest the following:

routePath = routePath.replace(/\/\/+/g, '/');

Copy link
Member

@255kb 255kb May 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True for the triple slashes, but the replace was fixed after the PR merge.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants