vinnylinux
vinnylinux

Reputation: 7034

Symfony 4 routing: multiple params with multiple slashes?

I've been trying to make this work for a while, without much luck:

file_show:
    path: /{user}/file/{group}/{file}
    controller: Acme\Controller\File::show
    requirements:
        group: .+
        file: .+


# /john/file/acme/group/test/file.zip
# user: john
# group: acme/group
# file: test/file.zip

Does the Symfony Router support multiple params with multiple slashes like this?

Upvotes: 0

Views: 1220

Answers (1)

Vyctorya
Vyctorya

Reputation: 1438

No symfony does not support multiple params with slashes straight after each other as ist can not know where one parameter ends and the next one begins.

# /john/file/acme/group/test/file.zip
# user: john
# group: acme/group             
# file: test/file.zip           

could also be

# /john/file/acme/group/test/file.zip
# user: john
# group: acme             
# file: group/test/file.zip  

You can work around this by using a different sign between the params and not allow that sign inside the params. docs

Upvotes: 2

Related Questions