[Update] Validation for non-supported paths#22
Open
dantehemerson wants to merge 2 commits intoghondar:masterfrom
Open
[Update] Validation for non-supported paths#22dantehemerson wants to merge 2 commits intoghondar:masterfrom
dantehemerson wants to merge 2 commits intoghondar:masterfrom
Conversation
dantehemerson
commented
Dec 19, 2020
| const middleware = | ||
| function(req: { baseUrl: string | string[] }, res: any, next: () => void) { | ||
| if(preLoadState) | ||
| if(req.baseUrl.indexOf('.') !== -1 || req.baseUrl.indexOf('api') !== -1 || req.baseUrl.indexOf('static') !== -1) |
Author
There was a problem hiding this comment.
When this occurs?
req.baseUrl.indexOf('.') !== -1
Owner
There was a problem hiding this comment.
when route path is assets, css o js file
dantehemerson
commented
Dec 19, 2020
Comment on lines
+3
to
+24
| describe(isReservedPath.name, () => { | ||
| it('should be true if path does an strict match', () => { | ||
| expect(isReservedPath('/.')).toBe(true) | ||
| expect(isReservedPath('/api')).toBe(true) | ||
| expect(isReservedPath('/static')).toBe(true) | ||
|
|
||
| // api versions | ||
| expect(isReservedPath('/api/v1')).toBe(true) | ||
|
|
||
| // static files | ||
| expect(isReservedPath('/static/image.png')).toBe(true) | ||
| }) | ||
|
|
||
| it('should be false if path does not an strict match', () => { | ||
| // ends | ||
| expect(isReservedPath('/strapi')).toBe(false) | ||
| expect(isReservedPath('/bar-static')).toBe(false) | ||
|
|
||
| // others | ||
| expect(isReservedPath('/random-path')).toBe(false) | ||
| }) | ||
| }) No newline at end of file |
Author
There was a problem hiding this comment.
I'm not sure if I'm covering all cases, what do you think?
I have doubts with . validation.
Owner
There was a problem hiding this comment.
mmm I think that favicon.ico would has be there as well
dantehemerson
commented
Dec 19, 2020
Comment on lines
+18
to
+19
| expect(isReservedPath('/strapi')).toBe(false) | ||
| expect(isReservedPath('/bar-static')).toBe(false) |
Author
There was a problem hiding this comment.
This is the purpose of this PR, I think it should support this type of paths
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.