Answers for "node js how get url path"

0

get current path nodejs

console.log("Current directory:", __dirname);
//OR
console.log("Current directory:", process.cwd());
//OR
const path = require("path");

const directoryName = path.basename(__dirname);
console.log(directoryName);
Posted by: Guest on March-24-2022
-1

js get path from url

var reg = /.+?\:\/\/.+?(\/.+?)(?:#|\?|$)/;
var pathname = reg.exec( 'http://www.somedomain.com/account/search?filter=a#top' )[1];
Posted by: Guest on April-29-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language