Skip to content
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

[FX-580] Add trailing slash to all requests #121

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ internal class EncryptionKeyService(
.newBuilder()
.addPathSegment(ForageConstants.PathSegment.ISO_SERVER)
.addPathSegment(ForageConstants.PathSegment.ENCRYPTION_ALIAS)
.addPathSegment("")
Copy link
Contributor

Choose a reason for hiding this comment

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

doing addPathSegment("") is not clear that we're adding a trailing slash.

Would doing something like adding this extension work:

// in `OkHttpClientBuilder.kt` or new file: `HttpUrlExtensions.kt`
fun HttpUrl.Builder.addTrailingSlash(): HttpUrl.Builder {
    return this.addPathSegment("")
}

// in encryption key service

 return httpUrl
            .newBuilder()
            .addPathSegment(ForageConstants.PathSegment.ISO_SERVER)
            .addPathSegment(ForageConstants.PathSegment.ENCRYPTION_ALIAS)
            .addTrailingSlash()
            .build()

alternatively, can you add comments for each call to addPathSegment("")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a pretty cool optimization I didn't know was possible :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

.build()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ internal class MessageStatusService(
.addPathSegment(ForageConstants.PathSegment.API)
.addPathSegment(ForageConstants.PathSegment.MESSAGE)
.addPathSegment(contentId)
.addPathSegment("")
.build()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ internal class PaymentMethodService(
.addPathSegment(ForageConstants.PathSegment.API)
.addPathSegment(ForageConstants.PathSegment.PAYMENT_METHODS)
.addPathSegment(paymentMethodRef)
.addPathSegment("")
.build()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ internal class PaymentService(
.addPathSegment(ForageConstants.PathSegment.API)
.addPathSegment(ForageConstants.PathSegment.PAYMENTS)
.addPathSegment(paymentRef)
.addPathSegment("")
.build()
}
}