Wednesday, 7 June 2017

Getting the visiting path without file name (with or without extension) by Node.js

I'm writing a node js application and I want to do specified file selecting when html file/user access to localhost:8080/codes/script.js it will list out script .js in specified path but the problem I met is I have other function such as extension-less URL working in same file there is a way by using var q = url.parse(req.url, true); and q.pathname but this way it'll include the file name in this case script.js, So I want to ask is there any way to get path before the file like /codes/ or /codes but in my case with extension-less URL enable the URL may be localhost:8080/codes/script instead of localhost:8080/codes/script.js So how can I get /codes this path without getting file name (with or without extension)



via Andrew

No comments:

Post a Comment