softwaremill / softwaremill/sttp
validation done by parse and safeApply functions of Uri
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 1.5k
- Forks
- 338
- Avg merge
- 8h 59m
- Merged PRs (30d)
- 13
Description
Hi,
I cannot understand the parse and safeApply functions of Uri
The following unit tests are OK.
import sttp.model.Uri
// scheme:[//[user:password@]host[:port]]path[?query][#fragment]
assert(Uri.safeApply("http://example.com/path?query=123#frag").isRight)
assert(Uri.safeApply("mailto:user@example.com").isRight)
assert(Uri.safeApply("ftp://user:pass@ftp.example.org:21/files").isRight)
But the following unit tests are KO : do I use correctly the API to validate an uri ?
// 1. Missing scheme
assert(Uri.safeApply("example.com/path").isLeft)
// 2. Invalid characters (unescaped)
assert(Uri.safeApply("http://example.com/space here").isLeft)
// 3. Invalid port number
assert(Uri.safeApply("http://example.com:999999/path").isLeft)
// 4. Malformed IPv6 address
assert(Uri.safeApply("http://[2001:db8::12345]/path").isLeft)
regards,
OD
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Uri.parse and Uri.safeApply entry points and run the supplied unit-test cases, comparing the successful examples with the four failing inputs. Determine whether those failures match the API's validation contract; done means the expected behavior for missing schemes, spaces, ports, and malformed IPv6 is clarified or corrected with focused tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100