johnroyer/url-normalizer
Composer 安装命令:
composer require johnroyer/url-normalizer
包简介
Syntax based normalization of URL's
README 文档
README
This URL normalizer is fork from glenscott/url-normalizer with some changes:
- upgrade PHPUnit to v9.x
- add parameter for removing tracking parameter (
utm_source,fbclid, etc)
Syntax based normalization of URI's
This normalizes URI's based on the specification RFC 3986 https://tools.ietf.org/html/rfc3986
Example usage
require_once 'vendor/autoload.php'; $url = 'eXAMPLE://a/./b/../b/%63/%7bfoo%7d'; $un = new URL\Normalizer( $url ); echo $un->normalize(); // Result: 'example://a/b/c/%7Bfoo%7D'
The normalization process preserves semantics
So, for example, the following URL's are all equivalent.
HTTP://www.Example.com/andhttp://www.example.com/http://www.example.com/a%c2%b1bandhttp://www.example.com/a%C2%B1bhttp://www.example.com/%7Eusername/andhttp://www.example.com/~username/http://www.example.comandhttp://www.example.com/http://www.example.com:80/bar.htmlandhttp://www.example.com/bar.htmlhttp://www.example.com/../a/b/../c/./d.htmlandhttp://www.example.com/a/c/d.htmlhttp://www.example.com/?array[key]=valueandhttp://www.example.com/?array%5Bkey%5D=value
Normalizations performed
- Converting the scheme and host to lower case
- Capitalizing letters in escape sequences
- Decoding percent-encoded octets of unreserved characters
- Adding trailing
/ - Removing the default port
- Removing dot-segments
For more information about these normalizations, please see the following Wikipedia article:
http://en.wikipedia.org/wiki/URL_normalization#Normalizations_that_Preserve_Semantics
For license information, please see LICENSE file.
Options
Two options are available when normalizing URLs which are disabled by default:
- Remove empty delimiters. Enabling this option would normalize
http://www.example.com/?tohttp://www.example.com/Currently, only the query string delimiter (?) is supported by this option. - Sort query parameters. Enabling this option sorts the query parameters by key alphabetically. For example,
http://www.example.com/?c=3&b=2&a=1becomeshttp://www.example.com/?a=1&b=2&c=3 - Remove tracking parameters. For examplem
https://example.com/?fbclid=xxxxxbecomeshttps://example.com/?
johnroyer/url-normalizer 适用场景与选型建议
johnroyer/url-normalizer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.64k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2023 年 09 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 johnroyer/url-normalizer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 johnroyer/url-normalizer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1.64k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 15
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-09-24