Skip to content

Commit 2fb3207

Browse files
committed
compatibility update
1 parent e7490a3 commit 2fb3207

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ pluginGroup = com.github.adrienpessu.sarifviewer
44
pluginName = SARIF-viewer
55
pluginRepositoryUrl = https://github.com/adrienpessu/SARIF-viewer
66
# SemVer format -> https://semver.org
7-
pluginVersion = 1.2.1
7+
pluginVersion = 1.2.2
88

99
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
1010
pluginSinceBuild = 223
11-
pluginUntilBuild = 241.*
11+
pluginUntilBuild = 242.*
1212

1313
# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
1414
platformType = IC

src/main/kotlin/com/github/adrienpessu/sarifviewer/services/SarifService.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import com.github.adrienpessu.sarifviewer.utils.GitHubInstance
1212
import com.intellij.openapi.components.Service
1313
import com.intellij.util.alsoIfNull
1414
import java.net.HttpURLConnection
15-
import java.net.URL
15+
import java.net.URI
1616

1717

1818
@Service(Service.Level.PROJECT)
@@ -117,7 +117,8 @@ class SarifService {
117117

118118
fun getPullRequests(github: GitHubInstance, repositoryFullName: String, branchName: String = "main"): List<*>? {
119119
val head = "${repositoryFullName.split("/")[0]}:$branchName"
120-
val connection = URL("${github.apiBase}/repos/$repositoryFullName/pulls?state=open&head=$head")
120+
val connection = URI("${github.apiBase}/repos/$repositoryFullName/pulls?state=open&head=$head")
121+
.toURL()
121122
.openConnection() as HttpURLConnection
122123

123124
connection.apply {
@@ -145,7 +146,8 @@ class SarifService {
145146
): String {
146147

147148
val s = "${github.apiBase}/repos/$repositoryFullName/code-scanning/analyses?ref=$branchName"
148-
val connection = URL(s)
149+
val connection = URI(s)
150+
.toURL()
149151
.openConnection() as HttpURLConnection
150152

151153
connection.apply {
@@ -188,7 +190,8 @@ class SarifService {
188190
}
189191

190192
private fun getSarifFromGitHub(github: GitHubInstance, repositoryFullName: String, analysisId: Int): String {
191-
val connection = URL("${github.apiBase}/repos/$repositoryFullName/code-scanning/analyses/$analysisId")
193+
val connection = URI("${github.apiBase}/repos/$repositoryFullName/code-scanning/analyses/$analysisId")
194+
.toURL()
192195
.openConnection() as HttpURLConnection
193196

194197
connection.apply {

src/main/kotlin/com/github/adrienpessu/sarifviewer/utils/GitHubInstance.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package com.github.adrienpessu.sarifviewer.utils
22

33
import org.jetbrains.annotations.VisibleForTesting
4-
import java.net.URL
4+
import java.net.URI
55

66
data class GitHubInstance(val hostname: String, val apiBase: String = "https://$hostname/api/v3") {
77
// Keep this out of the constructor so that it doesn't accidentally end up in a toString() output
88
var token: String = ""
99

1010
fun extractRepoNwo(remoteUrl: String?): String? {
1111
if (remoteUrl?.startsWith("https") == true) {
12-
return URL(remoteUrl).path.replace(Regex("^/"), "").replace(Regex(".git$"), "")
12+
return URI(remoteUrl).path.replace(Regex("^/"), "").replace(Regex(".git$"), "")
1313
} else if (remoteUrl?.startsWith("git@") == true) {
1414
return remoteUrl.replace(Regex("^git@$hostname:"), "").replace(Regex(".git$"), "")
1515
}
@@ -21,12 +21,13 @@ data class GitHubInstance(val hostname: String, val apiBase: String = "https://$
2121

2222
@VisibleForTesting
2323
fun extractHostname(remoteUrl: String?): String? {
24-
if (remoteUrl?.startsWith("https") == true) {
25-
return URL(remoteUrl).host
24+
return if (remoteUrl?.startsWith("https") == true) {
25+
URI(remoteUrl).host
2626
} else if (remoteUrl?.startsWith("git@") == true) {
27-
return remoteUrl.substringAfter("git@").substringBefore(":")
27+
remoteUrl.substringAfter("git@").substringBefore(":")
28+
} else {
29+
null
2830
}
29-
return null
3031
}
3132

3233
fun fromRemoteUrl(remoteUrl: String): GitHubInstance? {

0 commit comments

Comments
 (0)