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

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

Closed
wants to merge 1 commit into
from

Conversation

Projects
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 CONTRIBUTING.md 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

Owner

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 http://github.com/nodejs/io.js or http://github.com/nodejs/node

@jasnell jasnell closed this Aug 3, 2015

medikoo commented Aug 10, 2015

@jasnell at some point I'll probably propose it for http://github.com/nodejs/node 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.