承接 fleshgrinder/url-validator 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

fleshgrinder/url-validator

Composer 安装命令:

composer require fleshgrinder/url-validator

包简介

A regular expression to validate URLs.

README 文档

README

I made this repository specifically for Mathias Bynens' little “[in search of the perfect URL validation regex] (https://mathiasbynens.be/demo/url-regex)” challenge and if I may spoiler you from the beginning, mine is not perfect. But it is a step closer to it.

The regular expression contains parts from [Diego Perini's regular expression and the comments on his Gist] (https://gist.github.com/dperini/729294) as well as some stuff from the [Symfony URL constraint pattern] (https://github.com/symfony/Validator/blob/master/Constraints/UrlValidator.php#L34-L36).

Note that the challenge does not cover all possible valid URL constructs. The unit test contains several URLs which should be valid and not valid which are not part of the challenge.

Also note that this class is not meant as a real validator, it is more a starting point for a validator. I had to release the code under the MIT license because it incorporates a big portion of Diego Perini's regular expression—but I will ask him if it is possible for me to release it under the Unlicense license. If you plan to use this regular expression in your code consider to remove the username, password, port and IP address support; since such addresses should not be used for e.g. homepages of users on a profile page or within comments on a blog post.

On a last note, the class also contains a scheme (aka protocol) validation regular expression.

The provided unit test has a 100% coverage of the little class and the code is PHP 5.3+ compatible.

Features

  • Full Internationalized Domain Name (IDN) support.
  • Full support for Punycode.
  • Support for IPv4 and IPv6 addresses as hostname.
  • Extraction of URL parts (like parse_url):
    • Scheme (aka protocol)
    • Username
    • Password
    • Hostname
      • Domain + TLD
      • IPv4
      • IPv6
    • Port
    • Path
    • Query
    • Fragment

Install

The class and tests are available via composer.

composer require fleshgrinder/url-validator dev-master

TODO

  • IPv6 address validation totally relies on PHP's filter_var implementation, find a way to validate it with the regular expression.
  • Port the regular expression to JavaScript for usage in HTML input URL elements and of course JavaScript itself.
  • Find more funny URLs for the unit test.

Weblinks

License

The MIT License (MIT)

For more information, please refer to https://en.wikipedia.org/wiki/MIT_License

fleshgrinder/url-validator 适用场景与选型建议

fleshgrinder/url-validator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 29.83k 次下载、GitHub Stars 达 10, 最近一次更新时间为 2015 年 03 月 27 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「url」 「validation」 「uri」 「regex」 「regular expression」 「regexp」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 fleshgrinder/url-validator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 fleshgrinder/url-validator 我们能提供哪些服务?
定制开发 / 二次开发

基于 fleshgrinder/url-validator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 29.83k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 11
  • 点击次数: 25
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 10
  • Watchers: 1
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: Unlicense
  • 更新时间: 2015-03-27