Skip to content

Treat a trailing dot parent as the current directory in isWithin - #1007

Open
hamed75kazemii wants to merge 1 commit into
dart-lang:mainfrom
hamed75kazemii:fix-iswithin-trailing-dot
Open

hamed75kazemii wants to merge 1 commit into
dart-lang:mainfrom
hamed75kazemii:fix-iswithin-trailing-dot

Conversation

@hamed75kazemii

Copy link
Copy Markdown

Summary

  • isWithin('/dir/.', '/dir/.file') was false because the fast path matched the parent's trailing . against the first character of .file.
  • A lone . component means the current directory, so /dir/. is the same directory as /dir and contains /dir/.file. A name such as .bar is unchanged.
  • Covered with posix cases, and checked the same behavior on the Windows style.

Fixes #537

Test plan

  • Local checks: trailing-dot parent contains .file and file, equals /dir, and foo/./bar is still not a parent of foo/.bar/baz (posix and Windows)
  • dart test test/posix_test.dart --name isWithin inside pkgs/path (pub.dev was unreachable from this environment)

Made with Cursor

Comparing "/dir/." with "/dir/.file" matched the dot against the start of ".file" and reported the child as outside the directory.

Fixes dart-lang#537

Co-authored-by: Cursor <cursoragent@cursor.com>
@hamed75kazemii
hamed75kazemii requested a review from a team as a code owner October 10, 2026 19:06
@google-cla

google-cla Bot commented Oct 10, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

isWithin has surprising behavior when base ends with /. and child starts with .

1 participant