@@ -11,6 +11,7 @@ import java.net.URI
1111import java.net.http.HttpClient
1212import java.net.http.HttpRequest
1313import java.net.http.HttpResponse
14+ import java.nio.file.Paths
1415import java.util.*
1516
1617
@@ -22,14 +23,14 @@ class PushToBitburner {
2223 private val notificationGroup: NotificationGroup = NotificationGroupManager .getInstance()
2324 .getNotificationGroup(MyBundle .message(" groupId" ))
2425
25- fun pushToBitburner (file : VirtualFile , project : Project ? ) {
26+ fun pushToBitburner (file : VirtualFile , project : Project ) {
2627
2728
2829 val client = HttpClient .newBuilder().build()
2930 val request = HttpRequest .newBuilder()
3031 .header(" Authorization" , " Bearer " + BitburnerSettings .getAuthToken())
3132 .uri(uri)
32- .POST (HttpRequest .BodyPublishers .ofString(createJson(file)))
33+ .POST (HttpRequest .BodyPublishers .ofString(createJson(file, project )))
3334 .build()
3435 val response = client.send(request, HttpResponse .BodyHandlers .ofString())
3536 val status = response.statusCode()
@@ -42,8 +43,9 @@ class PushToBitburner {
4243
4344 }
4445
45- private fun createJson (file : VirtualFile ): String {
46- val fileName = file.name.replace(" /[\\\\ |/]+/g" , " /" )
46+ private fun createJson (file : VirtualFile , project : Project ): String {
47+ val relativePath = Paths .get(project.basePath!! ).relativize(Paths .get(file.path))
48+ val fileName = relativePath.toString().replace(" [\\\\ |/]+" .toRegex(), " /" )
4749
4850 val fileContent = String (file.contentsToByteArray())
4951 val encode = String (Base64 .getEncoder().encode(fileContent.toByteArray()))
0 commit comments