File tree Expand file tree Collapse file tree
frontend/src/main/scala/bloop/bsp Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package bloop .bsp
22
33import java .net .URI
4- import java .net .URLDecoder
5- import java .nio .charset .StandardCharsets
64import java .nio .file .Path
75
86import scala .util .Try
@@ -14,21 +12,16 @@ import bloop.engine.State
1412import bloop .io .AbsolutePath
1513
1614object ProjectUris {
15+ private val queryPrefix = " id="
1716 def getProjectDagFromUri (projectUri : String , state : State ): Either [String , Option [Project ]] = {
1817 if (projectUri.isEmpty) Left (" URI cannot be empty." )
1918 else {
20- val query = Try (new URI (projectUri).getRawQuery().split(" &" ).map(_.split(" =" ))).toEither
21- query match {
22- case Left (_) =>
19+ Try (new URI (projectUri).getQuery()).toEither match {
20+ case Right (query) if query.startsWith(queryPrefix) =>
21+ val projectName = query.stripPrefix(queryPrefix)
22+ Right (state.build.getProjectFor(projectName))
23+ case _ =>
2324 Left (s " URI ' ${projectUri}' has invalid format. Example: ${ProjectUris .Example }" )
24- case Right (parsed) =>
25- parsed.headOption match {
26- case Some (Array (" id" , projectName)) =>
27- val name = URLDecoder .decode(projectName, StandardCharsets .UTF_8 )
28- Right (state.build.getProjectFor(name))
29- case _ =>
30- Left (s " URI ' ${projectUri}' has invalid format. Example: ${ProjectUris .Example }" )
31- }
3225 }
3326 }
3427 }
@@ -43,7 +36,7 @@ object ProjectUris {
4336 existingUri.getHost,
4437 existingUri.getPort,
4538 existingUri.getPath,
46- s " id= ${id}" ,
39+ s " $queryPrefix ${id}" ,
4740 existingUri.getFragment
4841 )
4942 }
You can’t perform that action at this time.
0 commit comments