Path Normalize

Path Normalize

Medium NodeJS File System & Paths 33 views
Explanation Complexity

Problem Statement

Normalize a user given path and print the safe version.

Input Format

stdin: one path.

Output Format

Print normalized path.

Example

../meetcode//a/./b
..\\meetcode\\a\\b

Constraints

Use path.normalize only.

Input / Output Format

Input Format
stdin: one path.
Output Format
Print normalized path.
Constraints
Use path.normalize only.

Examples

Input:
../meetcode//a/./b
Output:
..\\meetcode\\a\\b

Example Solution (Public)

NodeJS
const fs = require('fs');
const path = require('path');
const raw = fs.readFileSync(0, 'utf8').trim();
if (!raw) process.exit(0);
console.log(path.normalize(raw));

Official Solution Code

const fs = require('fs');
const path = require('path');
const raw = fs.readFileSync(0, 'utf8').trim();
if (!raw) process.exit(0);
console.log(path.normalize(raw));
Please login to submit solutions.
Editor
Output

                                        
Please login to submit solutions.