【文件属性】:
文件名称:murl:murl 是 url 模式匹配和替换
文件大小:5KB
文件格式:ZIP
更新时间:2021-06-16 09:45:44
JavaScript
穆尔
murl 是快速的 url 模式匹配和替换。 它可以通过 npm 获得:
npm install murl
什么?
murl 公开一个接受模式的函数
var murl = require ( 'murl' )
var pattern = murl ( '/{hello}' )
如果您将字符串传递给模式 murl 将尝试匹配它
pattern ( '/world' ) // -> {hello:'world'}
如果您传递一个对象,它将替换为模式
pattern ( { hello : 'world' } ) // -> '/world'
图案
你可以用? 将组指定为可选
// matches both '/a' and '/a/b'
murl ( '/{hello}/{world}?' )
默认情况下, {}组匹配直到下一个字符或/ 。
// matches
【文件预览】:
murl-master
----LICENSE(1KB)
----README.md(1KB)
----tests()
--------test-match-strict.js(448B)
--------test-match-negative.js(252B)
--------test-match.js(432B)
--------test-replace.js(656B)
--------index.js(884B)
--------test-match-positive.js(849B)
----index.js(2KB)
----package.json(383B)