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

Replace ~ with os.homedir() when reading config.json #35

Merged
merged 4 commits into from
Aug 21, 2018

Conversation

modulated
Copy link
Contributor

Fix for issue: #3.

Checks if '~' is first character in path and replaces with os.homedir().

@klaudiosinani klaudiosinani self-requested a review August 7, 2018 16:16
@klaudiosinani klaudiosinani added the enhancement New feature or request label Aug 7, 2018
lib/config.js Outdated
@@ -29,6 +29,10 @@ class Config {
const content = fs.readFileSync(this._configFile, 'utf8');
config = JSON.parse(content);

if (config.taskbookDirectory[0] === '~') {
config.taskbookDirectory = config.taskbookDirectory.replace(/^~/, os.homedir());
Copy link
Owner

Choose a reason for hiding this comment

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

To construct the path more securely the path.join method can be used, instead of directly replacing ~ with the home directory:

config.taskbookDirectory = join(os.homedir(), config.taskbookDirectory.replace(/^~/g, ''));

Copy link
Owner

@klaudiosinani klaudiosinani left a comment

Choose a reason for hiding this comment

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

Looks good! A minor change and it is good to be merged : )

@klaudiosinani klaudiosinani merged commit 4ef7d20 into klaudiosinani:master Aug 21, 2018
@klaudiosinani
Copy link
Owner

Thank you for taking the time to contribute : )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants