zio-http
zio-http copied to clipboard
UserAgent regex broken in ScalaJS
Describe the bug
This blows up when its referenced in the browser.
https://github.com/zio/zio-http/blob/28c9de1d09b9d8da903dd80edda4a5c4277a5b88/zio-http/shared/src/main/scala/zio/http/Header.scala#L4151
To Reproduce On snapshot - 3.0.0-RC4+77-66867e7f-SNAPSHOT/
object Main extends ZIOAppDefault{
def run =
ZIO.succeed(Header.UserAgent)
}
Is this actually a zio http error? It seems like valid scala code is producing invalid js code. Is this a scalajs bug?
Regex's that are used in both JS and the JVM, must be compatible with both. No way around there being two different Regex engines.
@jamesward that's my point. I as a lib dev should not make sure that my regex works for both. That should be the scala js compiler/transpiler
I agree. But unfortunately I don't think Scala has any plans to write their own Regex engine. So the reality for now is that users have to write Regex that works on their target platforms.
Related (Almost decade-old) thread- https://github.com/scala-js/scala-js/issues/997#issuecomment-54197139
Okay 🙄 At least the issue is clear now.
One way around would be to not use regex at all for the header parsing but RichTextCodec
Would zio-parser be a viable option? One possible win would be that it is invertible.
RichTextCodec
is similar to zio parser and we would not have another dependency.
/bounty $250
~~## 💎 $250 bounty • ZIO~~
~~### Steps to solve:~~
~~1. Start working: Comment /attempt #2707
with your implementation plan~~
~~2. Submit work: Create a pull request including /claim #2707
in the PR body to claim the bounty~~
~~3. Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts~~
~~### Additional opportunities:~~
~~* 🔴 Livestream on Algora TV while solving this bounty & earn $200 upon merge! Make sure to have your camera and microphone on. Comment /livestream
once live~~
~~Thank you for contributing to zio/zio-http!~~
~~Add a bounty • Share on socials~~
Attempt | Started (GMT+0) | Solution |
---|---|---|
🟢 @pablf | Jun 15, 2024, 12:24:20 AM | #2912 |
/attempt #2707
Algora profile | Completed bounties | Tech | Active attempts | Options |
---|---|---|---|---|
@pablf | 24 ZIO bounties + 1 bounty from 1 project |
Scala, Rust |
Cancel attempt |
💡 @pablf submitted a pull request that claims the bounty. You can visit your bounty board to reward.