Uploaded image for project: 'Swift'
  1. Swift
  2. SR-6647

Inconsistency Behavior Of NSString.deletingPathExtension On macOS vs Linux

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Medium
    • Resolution: Done
    • Component/s: Foundation
    • Labels:
      None
    • Environment:

      Xcode Version 9.2 (9C40b)

      and

      commit c5c6cc861d6bfcb74035a07f493fab9617b1c36f on swift-corelibs-foundation, master as this bug is filed.

      Description

      The code in question:

      NSString(string: "..").deletingPathExtension
      

      On macOS, the result is ".." while on Linux, the result is ".". I think the former makes more sense since ".." represents parent directory on unix and treating part of it as file extension is a bit of a stretch. Another argument for aligning behavior to macOS is the fact that it existed longer therefore has more potential users.

       

      This bug manifests here: https://travis-ci.org/kylef/PathKit/builds/289637066

      The PathKit project CI is failing because it relies on this behavior and the example value is being used in tests on both macOS and Linux.

        Attachments

          Activity

            People

            Assignee:
            duan Daniel Duan
            Reporter:
            duan Daniel Duan
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: