New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Case insensitive routing #209

Merged
merged 4 commits into from Feb 13, 2018

Conversation

Projects
None yet
4 participants
@Joannis
Copy link
Member

Joannis commented Jan 24, 2018

#208 related

@Joannis Joannis added the enhancement label Jan 24, 2018

@Joannis Joannis self-assigned this Jan 24, 2018

@Joannis Joannis requested a review from tanner0101 Jan 24, 2018

@tanner0101 tanner0101 added this to the 3.0.0 milestone Feb 12, 2018

if self.caseInsensitive {
return data.caseInsensitiveEquals(to: buffer)
} else {
return memcmp(data, buffer.baseAddress!, size) == 0

This comment has been minimized.

@tanner0101

tanner0101 Feb 12, 2018

Member

@gwynne is there a more ABI-safe way to do this?

This comment has been minimized.

@gwynne

gwynne Feb 12, 2018

Contributor
return data.elementsEqual(buffer)

This comment has been minimized.

@kevinup7

kevinup7 Feb 12, 2018

Contributor

In addition to any safety issues, the use of memcmpcurrently causes a bug where routes with A and AA will always end up resolving to the A route.

This comment has been minimized.

@gwynne

gwynne Feb 12, 2018

Contributor

That's less memcmp()'s fault per se and more of an ordering logic error.

For the record, memcmp() is not really unsafe in this particular usage so much as it is bad style; one should always use the Swift stdlib whenever possible, even when working with raw pointers.

This comment has been minimized.

@tanner0101

tanner0101 Feb 13, 2018

Member

@gwynne you're the best! ty

This comment has been minimized.

@tanner0101

tanner0101 Feb 13, 2018

Member

@kevinup7 I will add a test case for that. That's a bug

@tanner0101 tanner0101 changed the title Case insensitive routing Case insensitive routing [beta.2] Feb 12, 2018

@tanner0101 tanner0101 added this to Todo in Vapor 3 Feb 12, 2018

@tanner0101 tanner0101 modified the milestones: 3.0.0, 3.0.0-beta.2 Feb 13, 2018

@tanner0101 tanner0101 changed the title Case insensitive routing [beta.2] Case insensitive routing Feb 13, 2018

@tanner0101 tanner0101 merged commit 617559f into beta Feb 13, 2018

1 check passed

ci/circleci: linux Your tests passed on CircleCI!
Details

@tanner0101 tanner0101 deleted the case-insensitive-routing branch Feb 13, 2018

@Joannis Joannis moved this from Todo to Done in Vapor 3 Feb 17, 2018

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