Thursday, 1 June 2017

Is there any risk to building URLs manually?

In node.js, it's possible to create paths to files using the standard path lib, e.g.:

const path = require('path');
const myPath = path.join('directory', 'file');

Is there any risk to building paths manually instead? For instance:

const myPath = 'directory/file';

I'm guessing it should be fine because:

  • There's nothing specifically in the docs about this.
  • I've never used an OS (even Windows) that doesn't accept / as a path separator.


via Armand

No comments:

Post a Comment