Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

path.extname does not follow API document when path contains '..' #2526

@otakustay

Description

@otakustay

in (http://nodejs.org/docs/latest/api/path.html#path.extname)[API document] the description of path.extname is as below:

Return the extension of the path, from the last '.' to end of string in the last portion of the path. If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string.

Note ext.pathname should read the last . character, but if I write

and if I write

path.extname('../')

it outputs:

'./'

also, path.extname should return an empty string if the first character is ., but if I write

path.extname('..');

it outputs:

'.'

it seems that path.extname does not work correctly when there are continous sequence of . character

I'm using node v0.6.7 for Windows and here is the exact test case:

C:\Users\GrayZhang>node -v
v0.6.7

C:\Users\GrayZhang>node
> var path = require('path')
undefined
> path.extname('..');
'.'
> path.extname('../');
'./'
> path.extname('./../');
'./'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions