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

Nullpointer Exception: Path("/").ext #1017

Closed
arberg opened this issue Nov 24, 2019 · 0 comments · Fixed by com-lihaoyi/os-lib#87
Closed

Nullpointer Exception: Path("/").ext #1017

arberg opened this issue Nov 24, 2019 · 0 comments · Fixed by com-lihaoyi/os-lib#87

Comments

@arberg
Copy link

arberg commented Nov 24, 2019

I'm suppose this is a (minor) bug: (ubuntu operating system)

Welcome to the Ammonite Repl 1.8.2

/home/app@ Path("/").ext
java.lang.NullPointerException
  os.Path.last(Path.scala:434)
  os.BasePathImpl.ext(Path.scala:185)
  os.BasePathImpl.ext$(Path.scala:184)
  os.Path.ext(Path.scala:423)
  ammonite.$sess.cmd1$.<clinit>(cmd1.sc:1)

Best Alex

lihaoyi added a commit to com-lihaoyi/os-lib that referenced this issue Dec 8, 2021
Fixes com-lihaoyi/Ammonite#1017

This is more consistent with calling `.ext` on non-empty paths which have no extension, since those currently return `""`

We also introduce a new a `lastOption`  method, as a way to get the last segment in a list without throwing. Not sure if that's the right thing to do, or whether we should make `.last` return `""` (which is otherwise not a valid return value, since path segments cannot be empty).

Covered with simple unit tests
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 a pull request may close this issue.

1 participant