Package Exports
- urls-js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (urls-js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
urls-js
轻量级url参数处理,兼容浏览器和Node.js环境
引用
var urls = require('urls');
urls.parse()
解析 url参数和 hash参数
假设当前页面 url 为 http://baidu.com?a=1&b=2#c=3
urls.parse().query; // ==> { a: '1', b: '2' }
urls.parse().hash; // ==> { c: '3' }urls.stringify()
把对象转为url字符串
var url = {
path: 'page/index.html',
query: {
a: 1,
b: 2
},
hash: {
c: ''
}
};
urls.stringify(url); // ==> page/index.html?a=1&b=2#curls.merge()
合并url参数
var url1 = 'page/index.html?a=1&b=2#c';
var url2 = '?b=3';
urls.merge(url1, url2); // ==> page/index.html?a=1&b=3#c
urls.merge(url1, {
query: {
b: 3
}
}); // ==> page/index.html?a=1&b=3#c