# joyent/node

### Subversion checkout URL

You can clone with
or
.

Open
wants to merge 1 commit into from
+139 −0

### 5 participants

var path = require('path');

path.common('/lorem/ipsum/foo/bar', '/lorem/ipsum/raz/dwa', '/lorem/elo/foo/bar'); //  => '/lorem'

path.common('/foo/bar', '/raz/dwa'); // => '/'

path.common('C:\\\\foo\\bar', 'D:\\\\foo\\bar'); // => null

I have use case for it in few of my modules (using counterparts for now), and I wonder why it's not part of path API.

I'll be happy to provide a pull request, but before that I'd like to be sure that you're open for such add on.

was assigned
Owner

@isaacs pretty sure I know your answer will be, but want you to have the final say. :)

referenced this pull request from a commit in medikoo/node
 medikoo path: path.common Fix #6328 c4c96de
 medikoo path: path.common Fix #6328 797cc00

Thank you for contributing this pull request! Here are a few pointers to make sure your submission will be considered for inclusion.

• Mariusz Nowak

You can fix all these things without opening another issue.

I've signed the CLA,

Please consider adding this feature. Otherwise I'll probably publish it with e.g. path-ext package. Thanks

Why path.common('C:\\\\foo\\bar', 'D:\\\\foo\\bar'); return null not ''?

@litmit '' resolves to current path (process.cwd()) and that's not valid result for that case

In a meantime I've published path.common with path2 package, a modular and extended version of path

Fix #6328