Skip to content

Commit cc82df0

Browse files
committed
Merge branch 'master' into publish
2 parents 8461411 + 285cfc6 commit cc82df0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+449
-449
lines changed

build.sbt

+7-4
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ inThisBuild(
2727
url("https://github.com/sherpal")
2828
)
2929
),
30-
crossScalaVersions := Seq("3.2.0", "2.13.5", "2.12.13"),
31-
scalaVersion := crossScalaVersions.value.head
30+
crossScalaVersions := Seq("3.3.1", "2.13.14", "2.12.19"),
31+
scalaVersion := crossScalaVersions.value.head,
32+
autoAPIMappings := true
3233
)
3334
)
3435

@@ -45,13 +46,15 @@ lazy val `url-dsl` = crossProject(JSPlatform, JVMPlatform)
4546
),
4647
(Compile / doc / scalacOptions) ++= Seq(
4748
"-no-link-warnings" // Suppress scaladoc "Could not find any member to link for" warnings
48-
)
49+
),
50+
Compile / doc / scalacOptions ~= ((options: Seq[String]) => options.filterNot(_ == "-Xfatal-warnings"))
4951
)
5052
.jsSettings(
5153
scalacOptions ++= sys.env.get("CI").map { _ =>
5254
val localSourcesPath = (LocalRootProject / baseDirectory).value.toURI
5355
val remoteSourcesPath = s"https://raw.githubusercontent.com/sherpal/url-dsl/${git.gitHeadCommit.value.get}/"
54-
val sourcesOptionName = if (scalaVersion.value.startsWith("2.")) "-P:scalajs:mapSourceURI" else "-scalajs-mapSourceURI"
56+
val sourcesOptionName =
57+
if (scalaVersion.value.startsWith("2.")) "-P:scalajs:mapSourceURI" else "-scalajs-mapSourceURI"
5558

5659
s"${sourcesOptionName}:$localSourcesPath->$remoteSourcesPath"
5760
}

project/build.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version = 1.8.0
1+
sbt.version = 1.10.0

project/plugins.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")
55
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0")
66

77
val scalaJSVersion =
8-
Option(System.getenv("SCALAJS_VERSION")).getOrElse("1.9.0")
8+
Option(System.getenv("SCALAJS_VERSION")).getOrElse("1.16.0")
99

1010
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0")
1111
addSbtPlugin("org.scala-js" % "sbt-scalajs" % scalaJSVersion)

url-dsl/.js/src/main/scala/urldsl/url/JSUrlStringParser.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ final class JSUrlStringParser(val rawUrl: String) extends UrlStringParser {
1212

1313
def maybeFragment: Option[String] =
1414
Option(urlParser.hash)
15-
/*
15+
/*
1616
* Empty fragment are considered to have no fragment at all
1717
*/
1818
.filter(_.nonEmpty)

url-dsl/.js/src/main/scala/urldsl/url/URL.scala

+3-6
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,19 @@ import scala.scalajs.js.annotation.JSGlobal
88
@JSGlobal
99
private[url] final class URL(url: String) extends js.Object {
1010

11-
/**
12-
* Is a DOMString containing an initial '/' followed by the path of the URL.
11+
/** Is a DOMString containing an initial '/' followed by the path of the URL.
1312
*
1413
* MDN
1514
*/
1615
var pathname: String = js.native
1716

18-
/**
19-
* Is a DOMString containing a '?' followed by the parameters of the URL.
17+
/** Is a DOMString containing a '?' followed by the parameters of the URL.
2018
*
2119
* MDN
2220
*/
2321
var search: String = js.native
2422

25-
/**
26-
* Is a DOMString containing a '#' followed by the fragment identifier of the URL.
23+
/** Is a DOMString containing a '#' followed by the fragment identifier of the URL.
2724
*
2825
* MDN
2926
*/

url-dsl/.jvm/src/main/scala/urldsl/url/JavaNetUrlStringParser.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package urldsl.url
22

3-
import java.net.{URL, URLDecoder}
3+
import java.net.{URI, URLDecoder}
44

55
final class JavaNetUrlStringParser(val rawUrl: String) extends UrlStringParser {
66

7-
private val urlParser = new URL(rawUrl)
7+
private val urlParser = URI.create(rawUrl).toURL()
88

99
def queryParametersString: String = Option(urlParser.getQuery).getOrElse("")
1010

url-dsl/src/main/scala-3/urldsl/vocabulary/FromStringWithNumeric.scala

+7-8
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@ import urldsl.errors.ErrorFromThrowable
44

55
trait FromStringWithNumeric {
66

7-
implicit def numericFromString[T, A](
8-
implicit num: Numeric[T],
7+
implicit def numericFromString[T, A](implicit
8+
num: Numeric[T],
99
fromThrowable: ErrorFromThrowable[A]
10-
): FromString[T, A] = FromString.factory(
11-
s =>
12-
num.parseString(s) match {
13-
case Some(t) => Right(t)
14-
case None => Left(fromThrowable.fromThrowable(new Exception(s"$s is not numeric")))
15-
}
10+
): FromString[T, A] = FromString.factory(s =>
11+
num.parseString(s) match {
12+
case Some(t) => Right(t)
13+
case None => Left(fromThrowable.fromThrowable(new Exception(s"$s is not numeric")))
14+
}
1615
)
1716

1817
}

url-dsl/src/main/scala/urldsl/errors/DummyError.scala

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package urldsl.errors
22
import urldsl.vocabulary.Segment
33

4-
/**
5-
* Error type with only one instance, for when you only care about knowing whether the error exists.
4+
/** Error type with only one instance, for when you only care about knowing whether the error exists.
65
*/
76
sealed trait DummyError
87

url-dsl/src/main/scala/urldsl/errors/ErrorFromThrowable.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package urldsl.errors
22

3-
/**
4-
* You can implement this trait for your own error type A, and give a implicit instance in order to use the
3+
/** You can implement this trait for your own error type A, and give a implicit instance in order to use the
54
* functionality requiring it, e.g., in [[urldsl.vocabulary.FromString]].
65
*
7-
* @tparam A tye type of your error.
6+
* @tparam A
7+
* tye type of your error.
88
*/
99
trait ErrorFromThrowable[A] {
1010

url-dsl/src/main/scala/urldsl/errors/ParamMatchingError.scala

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package urldsl.errors
22

3-
/**
4-
* You can implement this trait for your own error type `A`, and provide an implicit instance in the companion object of
5-
* `A` in order to use all pre-defined [[urldsl.language.QueryParameters]].
3+
/** You can implement this trait for your own error type `A`, and provide an implicit instance in the companion object
4+
* of `A` in order to use all pre-defined [[urldsl.language.QueryParameters]].
65
*
76
* @example
8-
* See implementations of [[DummyError]] and [[SimpleParamMatchingError]]
7+
* See implementations of [[DummyError]] and [[SimpleParamMatchingError]]
98
*
10-
* @tparam A the type of your error.
9+
* @tparam A
10+
* the type of your error.
1111
*/
1212
trait ParamMatchingError[A] {
1313
def missingParameterError(paramName: String): A

url-dsl/src/main/scala/urldsl/errors/PathMatchingError.scala

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ package urldsl.errors
22

33
import urldsl.vocabulary.Segment
44

5-
/**
6-
* You can implement this trait for your own error type `A`, a giving an implicit instance in the companion object of
5+
/** You can implement this trait for your own error type `A`, a giving an implicit instance in the companion object of
76
* `A` so that it is available for all pre-defined [[urldsl.language.PathSegment]].
87
*
98
* @example
10-
* See implementations of [[DummyError]] or [[SimpleParamMatchingError]]
9+
* See implementations of [[DummyError]] or [[SimpleParamMatchingError]]
1110
*
12-
* @tparam A type of the error.
11+
* @tparam A
12+
* type of the error.
1313
*/
1414
trait PathMatchingError[+A] {
1515

url-dsl/src/main/scala/urldsl/errors/SimpleParamMatchingError.scala

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ package urldsl.errors
22

33
sealed trait SimpleParamMatchingError
44

5-
/**
6-
* An implementation of [[ParamMatchingError]] that simply wraps the trigger of the error inside its components.
5+
/** An implementation of [[ParamMatchingError]] that simply wraps the trigger of the error inside its components.
76
*/
87
object SimpleParamMatchingError {
98

url-dsl/src/main/scala/urldsl/language/AllImpl.scala

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ package urldsl.language
22

33
import urldsl.errors.{FragmentMatchingError, ParamMatchingError, PathMatchingError}
44

5-
final class AllImpl[P, Q, F] private (
6-
implicit
5+
final class AllImpl[P, Q, F] private (implicit
76
protected val pathError: PathMatchingError[P],
87
protected val queryError: ParamMatchingError[Q],
98
protected val fragmentError: FragmentMatchingError[F]
@@ -12,8 +11,7 @@ final class AllImpl[P, Q, F] private (
1211
with FragmentImpl[F]
1312

1413
object AllImpl {
15-
def apply[P, Q, F](
16-
implicit
14+
def apply[P, Q, F](implicit
1715
pathError: PathMatchingError[P],
1816
queryError: ParamMatchingError[Q],
1917
fragmentError: FragmentMatchingError[F]

url-dsl/src/main/scala/urldsl/language/Fragment.scala

+47-44
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,30 @@ import urldsl.vocabulary.{Codec, FromString, MaybeFragment, Printer}
77
import scala.language.implicitConversions
88
import scala.reflect.ClassTag
99

10-
/**
11-
* Represents the fragment (or ref) of an URL, containing an information of type T, or an error of type E.
10+
/** Represents the fragment (or ref) of an URL, containing an information of type T, or an error of type E.
1211
*
13-
* @tparam T type represented by this PathSegment
14-
* @tparam E type of the error that this PathSegment produces on "illegal" url paths.
12+
* @tparam T
13+
* type represented by this PathSegment
14+
* @tparam E
15+
* type of the error that this PathSegment produces on "illegal" url paths.
1516
*/
1617
trait Fragment[T, +E] extends UrlPart[T, E] {
1718

1819
import Fragment.factory
1920

20-
/**
21-
* Extract the information contained in this fragment, as an instance of T.
21+
/** Extract the information contained in this fragment, as an instance of T.
2222
*
23-
* @param maybeFragment raw fragment information from the URL
24-
* @return Right a T when the extraction was successful, and Left an error otherwise.
23+
* @param maybeFragment
24+
* raw fragment information from the URL
25+
* @return
26+
* Right a T when the extraction was successful, and Left an error otherwise.
2527
*/
2628
def matchFragment(maybeFragment: MaybeFragment): Either[E, T]
2729

2830
def matchRawUrl(url: String, urlStringParserGenerator: UrlStringParserGenerator): Either[E, T] =
2931
matchFragment(urlStringParserGenerator.parser(url).maybeFragmentObj)
3032

31-
/**
32-
* Creates a fragment information from an instance of T.
33+
/** Creates a fragment information from an instance of T.
3334
*/
3435
def createFragment(t: T): MaybeFragment
3536

@@ -51,31 +52,33 @@ trait Fragment[T, +E] extends UrlPart[T, E] {
5152

5253
def as[U](implicit codec: Codec[T, U]): Fragment[U, E] = as[U](codec.leftToRight _, codec.rightToLeft _)
5354

54-
/**
55-
* Turns this fragment matching a `T` into a fragment matching an [[Option]] of T.
56-
* It will return Some(t) if t could be extracted, and None otherwise.
55+
/** Turns this fragment matching a `T` into a fragment matching an [[Option]] of T. It will return Some(t) if t could
56+
* be extracted, and None otherwise.
5757
*
5858
* The failure that happened and led to an error does not matter: it will result in None, no matter what.
5959
*/
6060
def ? : Fragment[Option[T], E] = factory(
6161
matchFragment(_) match {
6262
case Left(_) => Right(None)
6363
case Right(value) => Right(Some(value))
64-
}, {
64+
},
65+
{
6566
case Some(t) => createFragment(t)
6667
case None => MaybeFragment(None)
6768
}
6869
)
6970

70-
/**
71-
* Adds an extra satisfying criteria to the de-serialized output of this [[Fragment]].
72-
* When the output of this [[Fragment]] does not satisfy the given predicate, the given error is returned
73-
* instead.
71+
/** Adds an extra satisfying criteria to the de-serialized output of this [[Fragment]]. When the output of this
72+
* [[Fragment]] does not satisfy the given predicate, the given error is returned instead.
7473
*
75-
* @param predicate criteria that the output has to verify
76-
* @param error error happening when it's not the case
77-
* @tparam E1 new type of the error
78-
* @return a new [[Fragment]] matching the same fragment information, but only when the predicate is satisfied
74+
* @param predicate
75+
* criteria that the output has to verify
76+
* @param error
77+
* error happening when it's not the case
78+
* @tparam E1
79+
* new type of the error
80+
* @return
81+
* a new [[Fragment]] matching the same fragment information, but only when the predicate is satisfied
7982
*/
8083
final def filter[E1 >: E](predicate: T => Boolean, error: MaybeFragment => E1): Fragment[T, E1] =
8184
Fragment.factory[T, E1](
@@ -91,19 +94,20 @@ trait Fragment[T, +E] extends UrlPart[T, E] {
9194
this.asInstanceOf[Fragment[T, DummyError]].filter(predicate, _ => DummyError.dummyError)
9295
}
9396

94-
/**
95-
* Returns a [[Fragment]] which outputs the contents of this [[Fragment]] when result is a [[Some]] and the
96-
* specified `default` value otherwise.
97-
* When generating the path, it will only generate paths corresponding to the [[Some]] case.
97+
/** Returns a [[Fragment]] which outputs the contents of this [[Fragment]] when result is a [[Some]] and the specified
98+
* `default` value otherwise. When generating the path, it will only generate paths corresponding to the [[Some]]
99+
* case.
98100
*
99-
* @note This method is only available when `T =:= Option[U]`.
101+
* @note
102+
* This method is only available when `T =:= Option[U]`.
100103
*
101-
* @param default default value when output is empty
104+
* @param default
105+
* default value when output is empty
102106
*/
103107
final def getOrElse[U](default: => U)(implicit ev: T =:= Option[U]): Fragment[U, E] =
104108
factory[U, E](
105109
(maybeFragment: MaybeFragment) => matchFragment(maybeFragment).map(ev(_).getOrElse(default)),
106-
//(u: U) => createFragment(ev.flip(Some(u)))
110+
// (u: U) => createFragment(ev.flip(Some(u)))
107111
// we keep the ugliness below while supporting 2.12 todo[scala3] remove
108112
(u: U) => createFragment(Some(u).asInstanceOf[T])
109113
)
@@ -118,14 +122,13 @@ object Fragment {
118122
def createFragment(t: T): MaybeFragment = generator(t)
119123
}
120124

121-
/**
122-
* Creates a fragment matching any element of type `T`, as long as the [[urldsl.vocabulary.FromString]] can
125+
/** Creates a fragment matching any element of type `T`, as long as the [[urldsl.vocabulary.FromString]] can
123126
* de-serialize it.
124127
*
125128
* If the fragment is missing, returns an error.
126129
*/
127-
def fragment[T, A](
128-
implicit fromString: FromString[T, A],
130+
def fragment[T, A](implicit
131+
fromString: FromString[T, A],
129132
printer: Printer[T],
130133
fragmentMatchingError: FragmentMatchingError[A]
131134
): Fragment[T, A] = factory[T, A](
@@ -136,14 +139,13 @@ object Fragment {
136139
(printer.apply _).andThen(Some(_)).andThen(MaybeFragment.apply)
137140
)
138141

139-
/**
140-
* Creates a fragment matching any element of type `T`, as long as the [[urldsl.vocabulary.FromString]] can
142+
/** Creates a fragment matching any element of type `T`, as long as the [[urldsl.vocabulary.FromString]] can
141143
* de-serialize it.
142144
*
143145
* If the fragment is missing, returns None.
144146
*/
145-
final def maybeFragment[T, A](
146-
implicit fromString: FromString[T, A],
147+
final def maybeFragment[T, A](implicit
148+
fromString: FromString[T, A],
147149
printer: Printer[T],
148150
fragmentMatchingError: FragmentMatchingError[A]
149151
): Fragment[Option[T], A] = factory[Option[T], A](
@@ -163,8 +165,8 @@ object Fragment {
163165
(_: Unit) => MaybeFragment(None)
164166
)
165167

166-
implicit def asFragment[T, A](t: T)(
167-
implicit fromString: FromString[T, A],
168+
implicit def asFragment[T, A](t: T)(implicit
169+
fromString: FromString[T, A],
168170
printer: Printer[T],
169171
fragmentMatchingError: FragmentMatchingError[A],
170172
classTag: ClassTag[T]
@@ -173,11 +175,12 @@ object Fragment {
173175
case MaybeFragment(None) => Left(fragmentMatchingError.missingFragmentError)
174176
case MaybeFragment(Some(fragment)) =>
175177
fromString(fragment) match {
176-
case Left(value) => Left(value)
177-
case Right(decodedValue) => decodedValue match {
178-
case value: T if value == t => Right(())
179-
case _ => Left(fragmentMatchingError.wrongValue(decodedValue, t))
180-
}
178+
case Left(value) => Left(value)
179+
case Right(decodedValue) =>
180+
decodedValue match {
181+
case value: T if value == t => Right(())
182+
case _ => Left(fragmentMatchingError.wrongValue(decodedValue, t))
183+
}
181184
}
182185
},
183186
_ => MaybeFragment(Some(printer.print(t)))

0 commit comments

Comments
 (0)