1.0.2 • Published 7 years ago

urlpath v1.0.2

Weekly downloads
5
License
MIT
Repository
github
Last release
7 years ago

urlpath

url路径解析, 为了解决在拼接链接中多个/连接问题, 感谢 @52cik

code style fecs NPM Version NPM Downloads Linux Build Test Coverage


例子

urlpath('//xuexb.com/', '//static/a.js')                        // '//xuexb.com/static/a.js'

urlpath('http://xuexb.com/', '//', '//static//', '/a.js')       // 'http://xuexb.com/static/a.js'
urlpath('http://xuexb.com/////static///a.js')                   // 'http://xuexb.com/static/a.js'

请注意和 url.resolve 的区别:

url.resolve('http://example.com/', '/one')                      // 'http://example.com/one'
url.resolve('http://example.com/one', '/two')                   // 'http://example.com/two'


urlpath('http://example.com/', '/one')                          // 'http://example.com/one'
urlpath('http://example.com/one', '/one')                       // 'http://example.com/one/one'