File tree Expand file tree Collapse file tree 3 files changed +10
-3
lines changed
turbo/src/main/kotlin/dev/hotwire/turbo Expand file tree Collapse file tree 3 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package dev.hotwire.turbo.http
3
3
import android.webkit.WebResourceRequest
4
4
import android.webkit.WebResourceResponse
5
5
import dev.hotwire.turbo.session.TurboSession
6
+ import dev.hotwire.turbo.util.isHttpGetRequest
6
7
import dev.hotwire.turbo.util.logEvent
7
8
8
9
internal class TurboWebViewRequestInterceptor (val session : TurboSession ) {
@@ -38,8 +39,7 @@ internal class TurboWebViewRequestInterceptor(val session: TurboSession) {
38
39
}
39
40
40
41
private fun shouldInterceptRequest (request : WebResourceRequest ): Boolean {
41
- return request.method.equals(" GET" , ignoreCase = true ) &&
42
- request.url.scheme?.startsWith(" HTTP" , ignoreCase = true ) == true
42
+ return request.isHttpGetRequest()
43
43
}
44
44
45
45
private fun logCurrentVisitResult (url : String , result : TurboHttpRepository .Result ) {
Original file line number Diff line number Diff line change @@ -657,7 +657,8 @@ class TurboSession internal constructor(
657
657
*/
658
658
override fun shouldOverrideUrlLoading (view : WebView , request : WebResourceRequest ): Boolean {
659
659
val location = request.url.toString()
660
- val isColdBootRedirect = isColdBooting && currentVisit?.location != location
660
+ val isHttpRequest = request.isHttpGetRequest()
661
+ val isColdBootRedirect = isHttpRequest && isColdBooting && currentVisit?.location != location
661
662
val shouldOverride = isReady || isColdBootRedirect
662
663
663
664
// Don't allow onPageFinished to process its
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import android.animation.ArgbEvaluator
4
4
import android.animation.ValueAnimator
5
5
import android.content.Context
6
6
import android.os.Handler
7
+ import android.webkit.WebResourceRequest
7
8
import com.google.gson.Gson
8
9
import com.google.gson.GsonBuilder
9
10
import com.google.gson.reflect.TypeToken
@@ -37,6 +38,11 @@ internal fun File.deleteAllFilesInDirectory() {
37
38
}
38
39
}
39
40
41
+ internal fun WebResourceRequest.isHttpGetRequest (): Boolean {
42
+ return method.equals(" GET" , ignoreCase = true ) &&
43
+ url.scheme?.startsWith(" HTTP" , ignoreCase = true ) == true
44
+ }
45
+
40
46
internal fun Any.toJson (): String {
41
47
return gson.toJson(this )
42
48
}
You can’t perform that action at this time.
0 commit comments