Skip to content

[Update] Validation for non-supported paths#22

Open
dantehemerson wants to merge 2 commits intoghondar:masterfrom
dantecalderon:feature/improve-not-supported-paths
Open

[Update] Validation for non-supported paths#22
dantehemerson wants to merge 2 commits intoghondar:masterfrom
dantecalderon:feature/improve-not-supported-paths

Conversation

@dantehemerson
Copy link

No description provided.

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)
Copy link
Author

Choose a reason for hiding this comment

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

When this occurs?

req.baseUrl.indexOf('.') !== -1

Copy link
Owner

Choose a reason for hiding this comment

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

when route path is assets, css o js file

Copy link
Author

Choose a reason for hiding this comment

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

fixed

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
Copy link
Author

Choose a reason for hiding this comment

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

I'm not sure if I'm covering all cases, what do you think?

I have doubts with . validation.

Copy link
Owner

Choose a reason for hiding this comment

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

mmm I think that favicon.ico would has be there as well

Copy link
Author

Choose a reason for hiding this comment

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

fixed

Comment on lines +18 to +19
expect(isReservedPath('/strapi')).toBe(false)
expect(isReservedPath('/bar-static')).toBe(false)
Copy link
Author

Choose a reason for hiding this comment

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

This is the purpose of this PR, I think it should support this type of paths

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.

2 participants