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

fix for relativeTo with paths containing dots #1469

Merged
merged 1 commit into from Apr 15, 2024

Conversation

oldergod
Copy link
Member

Fixes #1468

Fix A (this PR)

image

Fix B (if you prefer)

image

Copy link
Collaborator

@Egorand Egorand left a comment

Choose a reason for hiding this comment

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

Early return feels better to me!

@@ -250,6 +250,11 @@ internal inline fun Path.commonRelativeTo(other: Path): Path {
"Impossible relative path to resolve: $this and $other"
}

if (other.segmentsBytes.size == 1 && other.segmentsBytes.first() == DOT) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit:

Suggested change
if (other.segmentsBytes.size == 1 && other.segmentsBytes.first() == DOT) {
if (other.singleOrNull() == DOT) {

Copy link
Member

Choose a reason for hiding this comment

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

Or this:

Suggested change
if (other.segmentsBytes.size == 1 && other.segmentsBytes.first() == DOT) {
if (other.bytes == DOT) {

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

@oldergod
Copy link
Member Author

oldergod commented Apr 15, 2024

LMAO (?) but Jvm8 doesn't do the "right" thing and fails with java.lang.AssertionError: expected:<Desktop/documents/a> but was:<../Desktop/documents/a>

@oldergod oldergod force-pushed the bquenaudon.2024-04-15.relativeToWithDot branch from dcb0fea to 4df5c8c Compare April 15, 2024 16:27
@oldergod oldergod enabled auto-merge April 15, 2024 16:27
@oldergod oldergod merged commit 9ac89e2 into master Apr 15, 2024
11 checks passed
@oldergod oldergod deleted the bquenaudon.2024-04-15.relativeToWithDot branch April 15, 2024 17:11
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.

Path.relativeTo does not respect 'current directory dot'
3 participants