Skip to content

Commit

Permalink
[FX-580] Add trailing slash to all requests (#121)
Browse files Browse the repository at this point in the history
* Add trailing slash to all requests

* Add function to httpUrl builder class

* Fix linting issue
  • Loading branch information
dleis612 authored Oct 4, 2023
1 parent 998a10c commit cd3a733
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.joinforage.forage.android

import okhttp3.HttpUrl
import kotlin.random.Random

/**
Expand All @@ -12,3 +13,7 @@ import kotlin.random.Random
internal fun getJitterAmount(random: Random = Random.Default): Int {
return random.nextInt(-25, 26)
}

internal fun HttpUrl.Builder.addTrailingSlash(): HttpUrl.Builder {
return this.addPathSegment("")
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.joinforage.forage.android.network

import com.joinforage.forage.android.addTrailingSlash
import com.joinforage.forage.android.core.telemetry.Log
import com.joinforage.forage.android.network.model.ForageApiResponse
import com.joinforage.forage.android.network.model.ForageError
Expand Down Expand Up @@ -37,6 +38,7 @@ internal class EncryptionKeyService(
.newBuilder()
.addPathSegment(ForageConstants.PathSegment.ISO_SERVER)
.addPathSegment(ForageConstants.PathSegment.ENCRYPTION_ALIAS)
.addTrailingSlash()
.build()
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.joinforage.forage.android.network

import com.joinforage.forage.android.addTrailingSlash
import com.joinforage.forage.android.core.telemetry.Log
import com.joinforage.forage.android.network.model.ForageApiResponse
import com.joinforage.forage.android.network.model.ForageError
Expand Down Expand Up @@ -43,6 +44,7 @@ internal class MessageStatusService(
.addPathSegment(ForageConstants.PathSegment.API)
.addPathSegment(ForageConstants.PathSegment.MESSAGE)
.addPathSegment(contentId)
.addTrailingSlash()
.build()
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.joinforage.forage.android.network

import com.joinforage.forage.android.addTrailingSlash
import com.joinforage.forage.android.core.telemetry.Log
import com.joinforage.forage.android.network.model.ForageApiResponse
import com.joinforage.forage.android.network.model.ForageError
Expand Down Expand Up @@ -48,6 +49,7 @@ internal class PaymentMethodService(
.addPathSegment(ForageConstants.PathSegment.API)
.addPathSegment(ForageConstants.PathSegment.PAYMENT_METHODS)
.addPathSegment(paymentMethodRef)
.addTrailingSlash()
.build()
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.joinforage.forage.android.network

import com.joinforage.forage.android.addTrailingSlash
import com.joinforage.forage.android.core.telemetry.Log
import com.joinforage.forage.android.network.model.ForageApiResponse
import com.joinforage.forage.android.network.model.ForageError
Expand Down Expand Up @@ -48,6 +49,7 @@ internal class PaymentService(
.addPathSegment(ForageConstants.PathSegment.API)
.addPathSegment(ForageConstants.PathSegment.PAYMENTS)
.addPathSegment(paymentRef)
.addTrailingSlash()
.build()
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.joinforage.forage.android.network

import com.joinforage.forage.android.addTrailingSlash
import com.joinforage.forage.android.core.telemetry.Log
import com.joinforage.forage.android.network.model.ForageApiResponse
import com.joinforage.forage.android.network.model.ForageError
Expand Down Expand Up @@ -54,7 +55,7 @@ internal class TokenizeCardService(
.newBuilder()
.addPathSegment(ForageConstants.PathSegment.API)
.addPathSegment(ForageConstants.PathSegment.PAYMENT_METHODS)
.addPathSegment("")
.addTrailingSlash()
.build()
}
}

0 comments on commit cd3a733

Please sign in to comment.