Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

strict replace, fix #3 #4

Closed
wants to merge 1 commit into from
Closed

strict replace, fix #3 #4

wants to merge 1 commit into from

Conversation

fritx
Copy link
Contributor

@fritx fritx commented Sep 11, 2015

It looks not so elegant, any idea??

var osHomedir = require('os-homedir');
var home = osHomedir();

module.exports = function (str) {
return str.replace(home, '~');
str += path.sep;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to use path.resolve(str) on the str, otherwise you'll end up with double // if the input string ends in a /.

@sindresorhus
Copy link
Owner

Wish the implementation could be simpler. I'll have to think about it.

@fritx
Copy link
Contributor Author

fritx commented Sep 11, 2015

@sindresorhus yeah, maybe a one-line regexp is a little bit better??

@sindresorhus
Copy link
Owner

@fritx That depends on the regex. Can you share the regex?

@fritx
Copy link
Contributor Author

fritx commented Sep 13, 2015

I'm pretty not sure about the regex xD

sindresorhus added a commit that referenced this pull request Sep 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants