Skip to content

Commit

Permalink
Handle regexp exception
Browse files Browse the repository at this point in the history
  • Loading branch information
eugene-tkachenko committed Aug 5, 2024
1 parent deb2fc7 commit e56faf4
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 10 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ dependencies {
// releaseImplementation project(':okhttp-requests-modifier-no-op')
// debugImplementation project(':okhttp-requests-modifier')

releaseImplementation ('io.nerdythings:okhttp-requests-modifier-no-op:1.0.0')
debugImplementation ('io.nerdythings:okhttp-requests-modifier:1.0.0')
releaseImplementation ('io.nerdythings:okhttp-requests-modifier-no-op:1.0.1')
debugImplementation ('io.nerdythings:okhttp-requests-modifier:1.0.1')
implementation ('io.nerdythings:okhttp-profiler:1.1.1')
}
2 changes: 1 addition & 1 deletion okhttp-requests-modifier-no-op/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ dependencies {

ext {
artifactId = "okhttp-requests-modifier-no-op"
releaseVersion = "1.0.0"
releaseVersion = "1.0.1"
libraryDescription = 'Empty implementation of the okhttp request modifier library. ' +
'Should be used in release builds.'
}
Expand Down
6 changes: 3 additions & 3 deletions okhttp-requests-modifier/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ android {

ext {
compose="1.6.8"
lifecycle="2.8.3"
lifecycle="2.8.4"
}

dependencies {
Expand All @@ -48,15 +48,15 @@ dependencies {
implementation("androidx.compose.ui:ui:$compose")
implementation("androidx.compose.ui:ui-tooling:$compose")

implementation("androidx.activity:activity-compose:1.9.0")
implementation("androidx.activity:activity-compose:1.9.1")
implementation 'com.google.code.gson:gson:2.11.0'

compileOnly 'com.squareup.okhttp3:okhttp:4.12.0'
}

ext {
artifactId = "okhttp-requests-modifier"
releaseVersion = "1.0.0"
releaseVersion = "1.0.1"
libraryDescription = 'OkHttp Client request changer. It can rewrite response code and body.'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import okhttp3.Response
import okhttp3.ResponseBody.Companion.toResponseBody
import java.io.File
import java.util.UUID
import java.util.regex.PatternSyntaxException

class DataModifier(private val context: Context) {

Expand Down Expand Up @@ -46,10 +47,14 @@ class DataModifier(private val context: Context) {

private fun getAllFilesByPath(path: String): List<File> =
pathModifiersList.mapNotNull {
val matches = Regex(it.first).matches(path)
if (matches) {
File(context.cacheDir, it.second).takeIf { file -> file.exists() }
} else {
try {
val matches = Regex(it.first).matches(path)
if (matches) {
File(context.cacheDir, it.second).takeIf { file -> file.exists() }
} else {
null
}
} catch (e: PatternSyntaxException) {
null
}
}
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit e56faf4

Please sign in to comment.