This repository has been archived by the owner. It is now read-only.

Add path.common(path1/*, ...pathn*/); #6328

wants to merge 1 commit into


None yet
6 participants

medikoo commented Feb 14, 2014

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.

@ghost ghost assigned isaacs Oct 16, 2013

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

medikoo added a commit to medikoo/node-joyent that referenced this pull request Feb 14, 2014

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

The following commiters were not found in the CLA:

  • Mariusz Nowak

You can fix all these things without opening another issue.

Please see for more information

medikoo commented Feb 14, 2014

I've signed the CLA,

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

litmit commented Feb 14, 2014

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

medikoo commented Feb 14, 2014

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

medikoo commented Feb 17, 2014

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


jasnell commented Aug 3, 2015

Closing due to lack of activity. Can revisit if someone is interested in updating the PR. Given that this is a feature request, however, it would need to be targeted at either or

@jasnell jasnell closed this Aug 3, 2015

medikoo commented Aug 10, 2015

@jasnell at some point I'll probably propose it for at this point as there are two projects, it hardly make sense

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