artistan/urlencode

允许在路由参数中使用Urlencoded斜杠和其他字符

1.0.2 2014-07-09 14:53 UTC

This package is auto-updated.

Last update: 2024-09-26 05:45:40 UTC


README

覆盖Laravel 4的默认路由,允许包括斜杠在内的所有字符进行编码!

Composer配置

在您的composer.json中将artistan urlencode包作为依赖项包含Packagist

"artistan/urlencode": "1.0.*"

安装

更新您的composer配置后,运行composer install以下载依赖项。

app/config/app.php中的提供者数组中添加ServiceProvider

'providers' => array(
    'Artistan\Urlencode\UrlencodeServiceProvider',
)

Apache conf https://httpd.apache.ac.cn/docs/2.2/mod/core.html#allowencodedslashes

AllowEncodedSlashes On|NoDecode

警告

Ensure all your routes are properly rawurlencoded!

This package will actually break your routing IF you do not have valid urls in your routes.

Laravel Bug修复

([Bug] 路由参数中的urlencoded斜杠)[laravel/framework#4338] 当前路由不允许在路径中使用urlencoded斜杠。当尝试创建包含部分号码的路由的电子商务解决方案时,这是一个问题,因为许多部分号码包含斜杠。还有很多制造商的名字或品牌中包含斜杠。此包提供允许uri在路由([a href="https://laravel.net.cn/docs/routing" rel="nofollow noindex noopener external ugc">https://laravel.net.cn/docs/routing])中包含编码斜杠和其他字符的功能,并且还可以(使用这些参数创建路由)[https://laravel.net.cn/docs/routing#route-parameters]。

一个示例URL可能为...

// https://stage.test.com/part/Cisco%20Systems%2C%20Inc/CISCO2851-SRST%2FK9

Route::any('/part/{mfg}/{part}',
    array(
        'uses' =>'Vendorname\Package\Controllers\Hardware\PartController@part',
        'as' => 'part_page'
    )
);

用法

换句话说,它将允许在路由中作为参数对所有字符进行rawurlencoded,而不会破坏参数和/或路由。