Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(500)

Issue 11512011: Handle relative paths where the trailing directory has an extension. (Closed)

Created:
8 years ago by Bob Nystrom
Modified:
8 years ago
Reviewers:
nweiz
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Handle relative paths where the trailing directory has an extension. Committed: https://code.google.com/p/dart/source/detail?r=15946

Patch Set 1 #

Total comments: 11

Patch Set 2 : Revise. #

Patch Set 3 : Fix merge bug. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+44 lines, -31 lines) Patch
M utils/pub/path.dart View 1 2 5 chunks +32 lines, -30 lines 0 comments Download
M utils/tests/pub/path/path_posix_test.dart View 1 2 1 chunk +5 lines, -0 lines 0 comments Download
M utils/tests/pub/path/path_windows_test.dart View 1 2 2 chunks +7 lines, -1 line 0 comments Download

Messages

Total messages: 5 (0 generated)
Bob Nystrom
8 years ago (2012-12-11 01:51:17 UTC) #1
nweiz
https://codereview.chromium.org/11512011/diff/1/utils/pub/path.dart File utils/pub/path.dart (right): https://codereview.chromium.org/11512011/diff/1/utils/pub/path.dart#newcode316 utils/pub/path.dart:316: if (parsed.hasTrailingSeparator) return parsed.toString(); I really don't like changing ...
8 years ago (2012-12-11 02:09:42 UTC) #2
Bob Nystrom
Thanks! https://codereview.chromium.org/11512011/diff/1/utils/pub/path.dart File utils/pub/path.dart (right): https://codereview.chromium.org/11512011/diff/1/utils/pub/path.dart#newcode316 utils/pub/path.dart:316: if (parsed.hasTrailingSeparator) return parsed.toString(); On 2012/12/11 02:09:42, nweiz ...
8 years ago (2012-12-11 02:24:59 UTC) #3
nweiz
lgtm https://codereview.chromium.org/11512011/diff/1/utils/pub/path.dart File utils/pub/path.dart (right): https://codereview.chromium.org/11512011/diff/1/utils/pub/path.dart#newcode316 utils/pub/path.dart:316: if (parsed.hasTrailingSeparator) return parsed.toString(); On 2012/12/11 02:24:59, Bob ...
8 years ago (2012-12-11 02:34:46 UTC) #4
Bob Nystrom
8 years ago (2012-12-11 02:47:01 UTC) #5
Thanks!

When we get some more time, I'm up for a discussion on the overall
strategy/model for trailing separators. I'd like to have a good answer there.

https://codereview.chromium.org/11512011/diff/1/utils/pub/path.dart
File utils/pub/path.dart (right):

https://codereview.chromium.org/11512011/diff/1/utils/pub/path.dart#newcode316
utils/pub/path.dart:316: if (parsed.hasTrailingSeparator) return
parsed.toString();
On 2012/12/11 02:34:46, nweiz wrote:
> On 2012/12/11 02:24:59, Bob Nystrom wrote:
> > This is how Python works.
> 
> But not Ruby :).
> 
> > I think it would be confusing if
> > withoutExtension("foo.bar/") returned "foo". I believe the expectation is
that
> > it will strip the extension from the file name, if there is a file at the
end
> of
> > the path. If you have a trailing separator, I don't think there's a file at
> the
> > end of the path.
> 
> I disagree. I believe the expectation is that it will strip the extension from
> the entry pointed to be the path (in this case, "foo.bar").
> 
> I think it's easier to see for the dual, extension(). It's relatively common
> that directories will have meaningful extensions that users will want to
> extract, and it's also relatively common that paths come directly from user
> input. We could be introducing subtle bugs where "some_command foo.ext" on the
> command line works, but "some_command foo.ext/" does not.
> 
> Here's a very real-world example: some Git servers use the ".git" suffix on
> directories to determine if a directory is supposed to be Git. It would be
> potentially confusing if such a server were sensitive to the presence of a
slash
> when finding directories.
> 
> It also forces users (and you, the API designer) to consider every API's
> behavior with respect to trailing slashes. For example, does
dirname("foo/bar")
> return "foo" or "foo/"? Why?

I'm more interested here in what dirname("foo/bar/") returns. Python and Ruby
diverge there too: Python returns "foo/bar" and Ruby "foo".

I'm OK with changing this, but we should change it consistently across all
methods. They should all ignore trailing separators or treat them as meaningful
(essentially as denoting a path with a trailing unnamed file).

Powered by Google App Engine
This is Rietveld 408576698