Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebjarService: Do not use OS-specific directory seperators #3326

Merged
merged 1 commit into from Apr 18, 2020

Conversation

fthomas
Copy link
Contributor

@fthomas fthomas commented Apr 14, 2020

Path#toString uses the OS-specific directory separator if a Path
contains of multiple components. On Windows this means that the
WebjarAsset#asset field might contain backslashes. The assets field
is then later used to load a resource which fails because of the
backslashes
.

This change always uses / as directory separator for the assets path
so that loading them works on all operating systems again.

Closes: #3304

`Path#toString` uses the OS-specific directory separator if a `Path`
contains of multiple components. On Windows this means that the
`WebjarAsset#asset` field might contain backslashes. The `assets` field
is then later used to load a resource which [fails because of the
backslashes](https://docs.oracle.com/javase/8/docs/api/java/lang/ClassLoader.html#getResources-java.lang.String-).

This change always uses `/` as directory separator for the assets path
so that loading them works on all operating systems again.

Closes: http4s#3304
aeons
aeons approved these changes Apr 15, 2020
private def asScalaIterator[A](underlying: java.util.Iterator[A]): Iterator[A] =
new Iterator[A] {
override def hasNext: Boolean = underlying.hasNext
override def next(): A = underlying.next()
}

Copy link
Member

@rossabaker rossabaker Apr 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could probably be moved to CollectionCompat, in case it's useful elsewhere, but I don't think that's introduced until 0.21.

Copy link
Contributor Author

@fthomas fthomas Apr 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I didn't noticed CollectionCompat. It exists on the series/0.20 branch. On series/0.21 it also has a CollectionConverters that could be used here.

@rossabaker rossabaker merged commit e6ab993 into http4s:series/0.20 Apr 18, 2020
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants