Hiển thị các bài đăng có nhãn Express.js route parameter with slashes. Hiển thị tất cả bài đăng
Hiển thị các bài đăng có nhãn Express.js route parameter with slashes. Hiển thị tất cả bài đăng

Express.js route parameter with slashes

 https://stackoverflow.com/questions/16829803/express-js-route-parameter-with-slashes

https://stackoverflow.com/questions/10020099/express-js-routing-optional-splat-param

Use /company/:id* (note trailing asterisk).

Full example

var express = require('express')();

express.use(express.router);

express.get('/company/:id*', function(req, res, next) {
    res.json({
        id: req.params['id'],
        path: req.params[0]
    });    
});

express.listen(8080);

This works for /path and /path/foo on express 4, note the * before ?.

router.get('/path/:id*?', function(req, res, next) {
    res.render('page', { title: req.params.id });
});

Suppose you have this url: /api/readFile/c:/a/a.txt

If you want req.params.path to be c::

'/api/readFile/:path*

If you want req.params.path to be c:/a/a.txt:

'/api/readFile/:path([^/]*)'

anti-pattern là gì

  Trong công nghệ và lập trình, Anti-pattern (mẫu phản diện) là những giải pháp bề ngoài có vẻ hiệu quả để giải quyết một vấn đề phổ biến, ...