8000 Merge pull request #1522 from gzm0/fix-uri · commonlisp/scala-js@a9857df · GitHub
[go: up one dir, main page]

Skip to content

Commit a9857df

Browse files
committed
Merge pull request scala-js#1522 from gzm0/fix-uri
Fix scala-js#1521: URI Fragment is not part of scheme-specific part
2 parents b3dc73b + 986ea42 commit a9857df

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

javalib/src/main/scala/java/net/URI.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -493,8 +493,8 @@ object URI {
493493
val absoluteURI = scheme+":(?:("+hier_part+")|("+opaque_part+"))" /*2CAPT*/
494494

495495
// relativeURI = ( net_path | abs_path | rel_path ) [ "?" query ]
496-
val relativeURI = /*2CAPT*/
497-
"(?:"+net_path+"|("+abs_path+")|("+rel_path+"))(?:\\?"+query+")?"
496+
val relativeURI = /*3CAPT*/
497+
"((?:"+net_path+"|("+abs_path+")|("+rel_path+"))(?:\\?"+query+")?)"
498498

499499
// URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ]
500500
val uriRef = "^(?:"+absoluteURI+"|"+relativeURI+")(?:#"+fragment+")?$"
@@ -513,8 +513,8 @@ object URI {
513513
final val AbsAbsPath = AbsNetPath+1
514514
final val AbsQuery = AbsAbsPath+1
515515
final val AbsOpaquePart = AbsQuery+1
516-
final val RelSchemeSpecificPart = 0 // It's the whole string
517-
final val RelAuthority = AbsOpaquePart+1
516+
final val RelSchemeSpecificPart = AbsOpaquePart+1 // Everything but the fragment
517+
final val RelAuthority = RelSchemeSpecificPart+1
518518
final val RelUserInfo = RelAuthority+1
519519
final val RelHost = RelUserInfo+1
520520
final val RelPort = RelHost+1

test-suite/src/test/scala/org/scalajs/testsuite/javalib/URITest.scala

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ object URITest extends JasmineTest {
100100
expectURI(new URI("docs/guide/collections/designfaq.html#28"), false, false)(
101101
path = "docs/guide/collections/designfaq.html",
102102
fragment = "28",
103-
schemeSpecificPart = "docs/guide/collections/designfaq.html#28"
103+
schemeSpecificPart = "docs/guide/collections/designfaq.html"
104104
)()
105105
expectURI(new URI("../../../demo/jfc/SwingSet2/src/SwingSet2.java"), false, false)(
106106
path = "../../../demo/jfc/SwingSet2/src/SwingSet2.java",
@@ -142,7 +142,16 @@ object URITest extends JasmineTest {
142142
expectURI(new URI("#foo"), false, false)(
143143
fragment = "foo",
144144
path = "",
145-
schemeSpecificPart = "#foo"
145+
schemeSpecificPart = ""
146+
)()
147+
}
148+
149+
it("should parse relative URIs with query and fragment") {
150+
expectURI(new URI("?query=1#foo"), false, false)(
151+
query = "query=1",
152+
fragment = "foo",
153+
path = "",
154+
schemeSpecificPart = "?query=1" 45FE ;
146155
)()
147156
}
148157

0 commit comments

Comments
 (0)
0