Skip to content

Commit

Permalink
Fixed the wrong example of use in ExpressJS
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrienCastex committed Nov 22, 2017
1 parent f349f34 commit 7777cb4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,11 @@ const app = express();
// Root path
// This will allow '/my/sub/path/folder/file.txt' to give '/folder/file.txt'
// in the WebDAV server
const pathRegex = /^\/?my\/sub\/path((\/[^\/]+)*)\/?$/;
app.get(pathRegex, (req, res) => {
const subUrl = pathRegex.exec(req.url)[1];
const pathRegex = /^(\/my\/sub\/path)((\/[^\/]+)*)\/?$/;
app.all(pathRegex, (req, res) => {
const matches = pathRegex.exec(req.url);
const subUrl = matches[2];
const root = matches[1]; // = '/my/sub/path'

// Set the sub path as the path of the request to point
// to the right resource in the WebDAV server
Expand Down

0 comments on commit 7777cb4

Please sign in to comment.