зеркало из https://github.com/nextcloud/news.git
update jsurl
This commit is contained in:
Родитель
45aa740351
Коммит
a08bccacef
|
@ -31,7 +31,7 @@
|
|||
"jquery": "~2.*",
|
||||
"momentjs": "~2.11.*",
|
||||
"es6-shim": "~0.*",
|
||||
"js-url": "~1.8.*",
|
||||
"js-url": "~2.*",
|
||||
"masonry": "~4.0.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,37 @@
|
|||
{
|
||||
"name": "js-url",
|
||||
"authors": [
|
||||
"Rob Nova <rob@websanova.com>"
|
||||
],
|
||||
"description": "A simple url parser for JavaScript.",
|
||||
"keywords": [
|
||||
"js",
|
||||
"javascript",
|
||||
"url",
|
||||
"parser"
|
||||
],
|
||||
"homepage": "https://github.com/websanova/js-url",
|
||||
"version": "1.8.8",
|
||||
"_release": "1.8.8",
|
||||
"license": "MIT",
|
||||
"main": [
|
||||
"url.js"
|
||||
],
|
||||
"ignore": [
|
||||
"lib",
|
||||
"gruntfile.js",
|
||||
"index.html",
|
||||
"package.json",
|
||||
"tests.js",
|
||||
"url.jquery.json"
|
||||
],
|
||||
"dependencies": {},
|
||||
"version": "2.1.0",
|
||||
"_release": "2.1.0",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "v1.8.8",
|
||||
"commit": "8bf3b91598ac153192675f4bc5060dd357f8f3ba"
|
||||
"tag": "v2.1.0",
|
||||
"commit": "eeb6ac8a86f6762e04c0a8b76ae444e6f8d57809"
|
||||
},
|
||||
"_source": "git://github.com/websanova/js-url.git",
|
||||
"_target": "~1.8.*",
|
||||
"_target": "~2.*",
|
||||
"_originalSource": "js-url"
|
||||
}
|
|
@ -1,35 +1,40 @@
|
|||
# url()
|
||||
|
||||
A simple, lightweight url parser for JavaScript (~1.6 Kb minified, ~0.6Kb gzipped).
|
||||
A simple, lightweight url parser for JavaScript (~1.7 Kb minified, ~0.7Kb gzipped).
|
||||
|
||||
* [Change Log](https://github.com/websanova/js-url/wiki/Change-Log)
|
||||
* [View the url demo](http://url.websanova.com)
|
||||
* [Download the lastest version of url](https://github.com/websanova/js-url/tags)
|
||||
|
||||
Also available for Node.js.
|
||||
|
||||
* [Download the lastest version of node-url](https://github.com/websanova/node-url/tags)
|
||||
|
||||
* [On GitHub as node-url](https://github.com/websanova/node-url)
|
||||
* [On Npm as wurl](https://www.npmjs.com/package/wurl)
|
||||
|
||||
## Notes
|
||||
|
||||
For path(1) and path(-1) will always act as if the path is in the form `/some/path/` regardless of whether the original path was `/some/path` or `/some/path/`.
|
||||
For path(1) and path(-1) will always act as if the path is in the form `/some/path/` regardless of whether the original path was `/some/path` or `some/path/`.
|
||||
|
||||
## Tld
|
||||
|
||||
There are two versions, `url.min.js` and `url-tld.min.jd`. The `tld` version contains a list of valid tld's making the file about 2kb larger. If you don't need support for it just use domain parts arguments (`url('-1')`) to get the tld pieces you need.
|
||||
|
||||
## Examples
|
||||
|
||||
```html
|
||||
http://rob:abcd1234@www.example.com/path/index.html?query1=test&silly=willy#test=hash&chucky=cheese
|
||||
http://rob:abcd1234@www.example.co.uk/path/index.html?query1=test&silly=willy&field[0]=zero&field[2]=two#test=hash&chucky=cheese
|
||||
```
|
||||
|
||||
```js
|
||||
url(); // http://rob:abcd1234@www.example.com/path/index.html?query1=test&silly=willy#test=hash&chucky=cheese
|
||||
url('domain'); // example.com
|
||||
url('hostname'); // www.example.com
|
||||
url(); // http://rob:abcd1234@www.example.co.uk/path/index.html?query1=test&silly=willy&field[0]=zero&field[2]=two#test=hash&chucky=cheese
|
||||
url('tld'); // co.uk
|
||||
url('domain'); // example.co.uk
|
||||
url('hostname'); // www.example.co.uk
|
||||
url('sub'); // www
|
||||
url('.0') // (an empty string)
|
||||
url('.0') // undefined
|
||||
url('.1') // www
|
||||
url('.2') // example
|
||||
url('.-1') // com
|
||||
url('.-1') // uk
|
||||
url('auth') // rob:abcd1234
|
||||
url('user') // rob
|
||||
url('pass') // abcd1234
|
||||
|
@ -41,25 +46,35 @@ url('filename'); // index
|
|||
url('fileext'); // html
|
||||
url('1'); // path
|
||||
url('2'); // index.html
|
||||
url('3'); // (an empty string)
|
||||
url('3'); // undefined
|
||||
url('-1'); // index.html
|
||||
url(1); // path
|
||||
url(2); // index.html
|
||||
url(-1); // index.html
|
||||
url('?'); // query1=test&silly=willy
|
||||
url('query'); // query1=test&silly=willy
|
||||
url('?'); // {query1: 'test', silly: 'willy', field: ['zero', undefined, 'two']}
|
||||
url('?silly'); // willy
|
||||
url('?poo'); // null
|
||||
url('#'); // test=hash&chucky=cheese
|
||||
url('field[0]') // zero
|
||||
url('field') // ['zero', undefined, 'two']
|
||||
url('hash'); // test=hash&chucky=cheese
|
||||
url('#'); // {test: 'hash', chucky: 'cheese'}
|
||||
url('#chucky'); // cheese
|
||||
url('#poo'); // null
|
||||
url('#poo'); // undefined
|
||||
```
|
||||
|
||||
Also supports `mailto`.
|
||||
|
||||
```js
|
||||
url('protocol', 'mailto:rob@websanova.com'); // mailto
|
||||
url('email', 'mailto:rob@websanova.com'); // rob@websanova.com
|
||||
|
||||
```
|
||||
|
||||
We can also pass a url in and use all the same options on it:
|
||||
|
||||
```js
|
||||
url('domain', 'test.www.example.com/path/here'); // example.com
|
||||
url('hostname', 'test.www.example.com/path/here'); // test.www.example.com
|
||||
url('sub', 'test.www.example.com/path/here'); // test.www
|
||||
url('protocol', 'www.example.com/path/here'); // http
|
||||
url('path', 'http://www.example.com:8080/some/path'); // /some/path
|
||||
url('port', 'http://www.example.com:8080/some/path'); // 8080
|
||||
|
@ -67,24 +82,20 @@ url('protocol', 'https://www.example.com:8080/some/path'); // https
|
|||
etc...
|
||||
```
|
||||
|
||||
|
||||
## jQuery
|
||||
|
||||
Also include is a jQuery version of the plugin that can be called via $.url() with all the same options. If you're already using jQuery it may be better to use the jQuery version to avoid namespacing issues.
|
||||
|
||||
|
||||
## Grunt.js
|
||||
|
||||
If you want to use Grunt you will need to install the required plugins locally using `npm install` in the root folder of your project. If you need to setup Grunt on your system you can follow my [Setting up Grunt.js](http://www.websanova.com/blog/javascript/how-to-setup-grunt) guide.
|
||||
|
||||
|
||||
## Resources
|
||||
|
||||
* [More jQuery plugins by Websanova](http://websanova.com/plugins)
|
||||
* [jQuery Plugin Development Boilerplate](http://wboiler.websanova.com)
|
||||
* [The Ultimate Guide to Writing jQuery Plugins](http://www.websanova.com/blog/jquery/the-ultimate-guide-to-writing-jquery-plugins)
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT licensed
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"name": "js-url",
|
||||
"authors": [
|
||||
"Rob Nova <rob@websanova.com>"
|
||||
],
|
||||
"description": "A simple url parser for JavaScript.",
|
||||
"keywords": [
|
||||
"js",
|
||||
"javascript",
|
||||
"url",
|
||||
"parser"
|
||||
],
|
||||
"homepage": "https://github.com/websanova/js-url",
|
||||
"license": "MIT",
|
||||
"main": [
|
||||
"url.js"
|
||||
],
|
||||
"ignore": [
|
||||
"lib",
|
||||
"gruntfile.js",
|
||||
"index.html",
|
||||
"package.json",
|
||||
"tests.js",
|
||||
"url.jquery.json"
|
||||
],
|
||||
"dependencies": {}
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
module.exports = function(grunt) {
|
||||
grunt.initConfig({
|
||||
pkg: grunt.file.readJSON('package.json'),
|
||||
qunit: {
|
||||
files: ['index.html']
|
||||
},
|
||||
jshint: {
|
||||
options: {
|
||||
curly: true,
|
||||
eqeqeq: true,
|
||||
immed: true,
|
||||
latedef: true,
|
||||
newcap: true,
|
||||
noarg: true,
|
||||
sub: true,
|
||||
undef: true,
|
||||
boss: true,
|
||||
eqnull: true,
|
||||
globals: {
|
||||
'window': true,
|
||||
'jQuery': true
|
||||
}
|
||||
},
|
||||
files: {
|
||||
src: ['./url.js']
|
||||
}
|
||||
},
|
||||
uglify: {
|
||||
options: {
|
||||
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %> */'
|
||||
},
|
||||
my_target: {
|
||||
files: {
|
||||
'./url.min.js': ['./url.js']
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
grunt.loadNpmTasks('grunt-contrib-qunit');
|
||||
grunt.loadNpmTasks('grunt-contrib-jshint');
|
||||
grunt.loadNpmTasks('grunt-contrib-uglify');
|
||||
|
||||
grunt.registerTask('default', [ 'qunit', 'jshint', 'uglify' ]);
|
||||
};
|
|
@ -1,24 +0,0 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>url test</title>
|
||||
|
||||
<link rel="stylesheet" href="lib/qunit/qunit.css" media="screen">
|
||||
<script src="lib/jquery-1.10.1.min.js"></script>
|
||||
<script src="lib/qunit/qunit.js"></script>
|
||||
<script src="./url.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="qunit-header">Test Suite</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<div id="qunit-testrunner-toolbar"></div>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests"></ol>
|
||||
<div id="qunit-fixture">
|
||||
</div>
|
||||
|
||||
<script src="tests.js"></script>
|
||||
</body>
|
||||
</html>
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -1,232 +0,0 @@
|
|||
/**
|
||||
* QUnit v1.4.0 - A JavaScript Unit Testing Framework
|
||||
*
|
||||
* http://docs.jquery.com/QUnit
|
||||
*
|
||||
* Copyright (c) 2012 John Resig, Jörn Zaefferer
|
||||
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
||||
* or GPL (GPL-LICENSE.txt) licenses.
|
||||
*/
|
||||
|
||||
/** Font Family and Sizes */
|
||||
|
||||
#qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult {
|
||||
font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif;
|
||||
}
|
||||
|
||||
#qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; }
|
||||
#qunit-tests { font-size: smaller; }
|
||||
|
||||
|
||||
/** Resets */
|
||||
|
||||
#qunit-tests, #qunit-tests ol, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
|
||||
/** Header */
|
||||
|
||||
#qunit-header {
|
||||
padding: 0.5em 0 0.5em 1em;
|
||||
|
||||
color: #8699a4;
|
||||
background-color: #0d3349;
|
||||
|
||||
font-size: 1.5em;
|
||||
line-height: 1em;
|
||||
font-weight: normal;
|
||||
|
||||
border-radius: 15px 15px 0 0;
|
||||
-moz-border-radius: 15px 15px 0 0;
|
||||
-webkit-border-top-right-radius: 15px;
|
||||
-webkit-border-top-left-radius: 15px;
|
||||
}
|
||||
|
||||
#qunit-header a {
|
||||
text-decoration: none;
|
||||
color: #c2ccd1;
|
||||
}
|
||||
|
||||
#qunit-header a:hover,
|
||||
#qunit-header a:focus {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#qunit-header label {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
#qunit-banner {
|
||||
height: 5px;
|
||||
}
|
||||
|
||||
#qunit-testrunner-toolbar {
|
||||
padding: 0.5em 0 0.5em 2em;
|
||||
color: #5E740B;
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
#qunit-userAgent {
|
||||
padding: 0.5em 0 0.5em 2.5em;
|
||||
background-color: #2b81af;
|
||||
color: #fff;
|
||||
text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
|
||||
}
|
||||
|
||||
|
||||
/** Tests: Pass/Fail */
|
||||
|
||||
#qunit-tests {
|
||||
list-style-position: inside;
|
||||
}
|
||||
|
||||
#qunit-tests li {
|
||||
padding: 0.4em 0.5em 0.4em 2.5em;
|
||||
border-bottom: 1px solid #fff;
|
||||
list-style-position: inside;
|
||||
}
|
||||
|
||||
#qunit-tests.hidepass li.pass, #qunit-tests.hidepass li.running {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#qunit-tests li strong {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#qunit-tests li a {
|
||||
padding: 0.5em;
|
||||
color: #c2ccd1;
|
||||
text-decoration: none;
|
||||
}
|
||||
#qunit-tests li a:hover,
|
||||
#qunit-tests li a:focus {
|
||||
color: #000;
|
||||
}
|
||||
|
||||
#qunit-tests ol {
|
||||
margin-top: 0.5em;
|
||||
padding: 0.5em;
|
||||
|
||||
background-color: #fff;
|
||||
|
||||
border-radius: 15px;
|
||||
-moz-border-radius: 15px;
|
||||
-webkit-border-radius: 15px;
|
||||
|
||||
box-shadow: inset 0px 2px 13px #999;
|
||||
-moz-box-shadow: inset 0px 2px 13px #999;
|
||||
-webkit-box-shadow: inset 0px 2px 13px #999;
|
||||
}
|
||||
|
||||
#qunit-tests table {
|
||||
border-collapse: collapse;
|
||||
margin-top: .2em;
|
||||
}
|
||||
|
||||
#qunit-tests th {
|
||||
text-align: right;
|
||||
vertical-align: top;
|
||||
padding: 0 .5em 0 0;
|
||||
}
|
||||
|
||||
#qunit-tests td {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
#qunit-tests pre {
|
||||
margin: 0;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
#qunit-tests del {
|
||||
background-color: #e0f2be;
|
||||
color: #374e0c;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#qunit-tests ins {
|
||||
background-color: #ffcaca;
|
||||
color: #500;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
/*** Test Counts */
|
||||
|
||||
#qunit-tests b.counts { color: black; }
|
||||
#qunit-tests b.passed { color: #5E740B; }
|
||||
#qunit-tests b.failed { color: #710909; }
|
||||
|
||||
#qunit-tests li li {
|
||||
margin: 0.5em;
|
||||
padding: 0.4em 0.5em 0.4em 0.5em;
|
||||
background-color: #fff;
|
||||
border-bottom: none;
|
||||
list-style-position: inside;
|
||||
}
|
||||
|
||||
/*** Passing Styles */
|
||||
|
||||
#qunit-tests li li.pass {
|
||||
color: #5E740B;
|
||||
background-color: #fff;
|
||||
border-left: 26px solid #C6E746;
|
||||
}
|
||||
|
||||
#qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; }
|
||||
#qunit-tests .pass .test-name { color: #366097; }
|
||||
|
||||
#qunit-tests .pass .test-actual,
|
||||
#qunit-tests .pass .test-expected { color: #999999; }
|
||||
|
||||
#qunit-banner.qunit-pass { background-color: #C6E746; }
|
||||
|
||||
/*** Failing Styles */
|
||||
|
||||
#qunit-tests li li.fail {
|
||||
color: #710909;
|
||||
background-color: #fff;
|
||||
border-left: 26px solid #EE5757;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
#qunit-tests > li:last-child {
|
||||
border-radius: 0 0 15px 15px;
|
||||
-moz-border-radius: 0 0 15px 15px;
|
||||
-webkit-border-bottom-right-radius: 15px;
|
||||
-webkit-border-bottom-left-radius: 15px;
|
||||
}
|
||||
|
||||
#qunit-tests .fail { color: #000000; background-color: #EE5757; }
|
||||
#qunit-tests .fail .test-name,
|
||||
#qunit-tests .fail .module-name { color: #000000; }
|
||||
|
||||
#qunit-tests .fail .test-actual { color: #EE5757; }
|
||||
#qunit-tests .fail .test-expected { color: green; }
|
||||
|
||||
#qunit-banner.qunit-fail { background-color: #EE5757; }
|
||||
|
||||
|
||||
/** Result */
|
||||
|
||||
#qunit-testresult {
|
||||
padding: 0.5em 0.5em 0.5em 2.5em;
|
||||
|
||||
color: #2b81af;
|
||||
background-color: #D2E0E6;
|
||||
|
||||
border-bottom: 1px solid white;
|
||||
}
|
||||
|
||||
/** Fixture */
|
||||
|
||||
#qunit-fixture {
|
||||
position: absolute;
|
||||
top: -10000px;
|
||||
left: -10000px;
|
||||
width: 1000px;
|
||||
height: 1000px;
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,23 +0,0 @@
|
|||
{
|
||||
"name": "url",
|
||||
"version": "1.8.6",
|
||||
"description": "A simple, lightweight url parser for JavaScript (~1.6 Kb minified, ~0.6Kb gzipped).",
|
||||
"main": "url.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/websanova/js-url"
|
||||
},
|
||||
"author": {
|
||||
"name" : "Websanova"
|
||||
},
|
||||
"homepage" : "http://url.websanova.com",
|
||||
"license": "MIT, GPL",
|
||||
"dependencies": {
|
||||
"grunt-contrib-qunit": "",
|
||||
"grunt-contrib-uglify": "",
|
||||
"grunt-contrib-jshint": ""
|
||||
},
|
||||
"scripts": {
|
||||
"prepublish": "grunt"
|
||||
}
|
||||
}
|
|
@ -1,140 +0,0 @@
|
|||
(function() {
|
||||
|
||||
var url = 'http://rob:abcd1234@www.domain.com/path/index.html?query1=test&silly=willy#test=hash&chucky=cheese';
|
||||
var urlHttps = 'https://rob:abcd1234@www.domain.com/path/index.html?query1=test&silly=willy#test=hash&chucky=cheese';
|
||||
var urlIp = 'https://rob:abcd1234@1.2.3.4/path/index.html?query1=test&silly=willy#test=hash&chucky=cheese';
|
||||
|
||||
module('url');
|
||||
|
||||
test('url', function() {
|
||||
deepEqual( window.url( ), window.location.href );
|
||||
});
|
||||
|
||||
test('domain', function() {
|
||||
deepEqual( window.url( 'domain', url ), 'domain.com' );
|
||||
deepEqual( window.url( 'domain', urlIp ), '1.2.3.4' );
|
||||
});
|
||||
|
||||
test('hostname', function() {
|
||||
deepEqual( window.url( 'hostname', url ), 'www.domain.com' );
|
||||
});
|
||||
|
||||
test('sub', function() {
|
||||
deepEqual( window.url( 'sub', url ), 'www' );
|
||||
});
|
||||
|
||||
test('domain parts', function() {
|
||||
deepEqual( window.url( '.0', url ), '' );
|
||||
deepEqual( window.url( '.1', url ), 'www' );
|
||||
deepEqual( window.url( '.2', url ), 'domain' );
|
||||
deepEqual( window.url( '.-1', url ), 'com' );
|
||||
});
|
||||
|
||||
test('auth', function() {
|
||||
deepEqual( window.url( 'auth', url ), 'rob:abcd1234' );
|
||||
});
|
||||
|
||||
test('user', function() {
|
||||
deepEqual( window.url( 'user', url ), 'rob' );
|
||||
});
|
||||
|
||||
test('pass', function() {
|
||||
deepEqual( window.url( 'pass', url ), 'abcd1234' );
|
||||
});
|
||||
|
||||
test('port', function() {
|
||||
deepEqual( window.url( 'port', url ), '80' );
|
||||
deepEqual( window.url( 'port', url.toUpperCase() ), '80' );
|
||||
deepEqual( window.url( 'port', "http://example.com:80" ), '80' );
|
||||
deepEqual( window.url( 'port', urlHttps ), '443' );
|
||||
deepEqual( window.url( 'port', urlHttps.toUpperCase() ), '443' );
|
||||
deepEqual( window.url( 'port', "https://example.com:443" ), '443' );
|
||||
});
|
||||
|
||||
test('protocol', function() {
|
||||
deepEqual( window.url( 'protocol', url ), 'http' );
|
||||
});
|
||||
|
||||
test('path', function() {
|
||||
deepEqual( window.url( 'path', url ), '/path/index.html' );
|
||||
deepEqual( window.url( 'path', 'http://www.domain.com/first/second' ), '/first/second' );
|
||||
deepEqual( window.url( 'path', 'http://www.domain.com/first/second/' ), '/first/second/' );
|
||||
deepEqual( window.url( 'path', 'http://www.domain.com:8080/first/second' ), '/first/second' );
|
||||
deepEqual( window.url( 'path', 'http://www.domain.com:8080/first/second/' ), '/first/second/' );
|
||||
deepEqual( window.url( 'path', 'http://www.domain.com/first/second?test=foo' ), '/first/second' );
|
||||
deepEqual( window.url( 'path', 'http://www.domain.com/first/second/?test=foo' ), '/first/second/' );
|
||||
deepEqual( window.url( 'path', 'http://www.domain.com/path#anchor' ), '/path' );
|
||||
deepEqual( window.url( 'path', 'http://www.domain.com/path/#anchor' ), '/path/' );
|
||||
deepEqual( window.url( 'path', 'http://www.domain.com' ), '' );
|
||||
deepEqual( window.url( 'path', 'http://www.domain.com/' ), '/' );
|
||||
deepEqual( window.url( 'path', 'http://www.domain.com#anchor' ), '' );
|
||||
deepEqual( window.url( 'path', 'http://www.domain.com/#anchor' ), '/' );
|
||||
deepEqual( window.url( 'path', 'http://www.domain.com?test=foo' ), '' );
|
||||
deepEqual( window.url( 'path', 'http://www.domain.com/?test=foo' ), '/' );
|
||||
deepEqual( window.url( 'path', 'http://www.domain.com:80' ), '' );
|
||||
deepEqual( window.url( 'path', 'http://www.domain.com:80/' ), '/' );
|
||||
deepEqual( window.url( 'path', 'http://www.domain.com:80#anchor' ), '' );
|
||||
deepEqual( window.url( 'path', 'http://www.domain.com:80/#anchor' ), '/' );
|
||||
deepEqual( window.url( 'path', 'http://www.domain.com:80?test=foo' ), '' );
|
||||
deepEqual( window.url( 'path', 'http://www.domain.com:80/?test=foo' ), '/' );
|
||||
});
|
||||
|
||||
test('file', function() {
|
||||
deepEqual( window.url( 'file', url ), 'index.html' );
|
||||
deepEqual( window.url( 'filename', url ), 'index' );
|
||||
deepEqual( window.url( 'fileext', url ), 'html' );
|
||||
});
|
||||
|
||||
test('url parts', function() {
|
||||
deepEqual( window.url( '1', url ), 'path' );
|
||||
deepEqual( window.url( 1, url ), 'path' );
|
||||
|
||||
deepEqual( window.url( '2', url ), 'index.html' );
|
||||
deepEqual( window.url( '3', url ), '' );
|
||||
deepEqual( window.url( '-1', url ), 'index.html' );
|
||||
|
||||
deepEqual( window.url( '1', 'http://www.domain.com/first/second' ), 'first' );
|
||||
deepEqual( window.url( '1', 'http://www.domain.com/first/second/' ), 'first' );
|
||||
deepEqual( window.url( '-1', 'http://www.domain.com/first/second?test=foo' ), 'second' );
|
||||
deepEqual( window.url( '-1', 'http://www.domain.com/first/second/?test=foo' ), 'second' );
|
||||
});
|
||||
|
||||
test('query string', function() {
|
||||
deepEqual( window.url( '?', url ), 'query1=test&silly=willy' );
|
||||
deepEqual( window.url( '?silly', url ), 'willy' );
|
||||
deepEqual( window.url( '?poo', url ), null );
|
||||
|
||||
deepEqual( window.url( '?poo', 'http://domain.com?poo=' ), '' );
|
||||
deepEqual( window.url( '?poo', 'http://domain.com/?poo' ), '' );
|
||||
deepEqual( window.url( '?poo', 'http://domain.com?poo' ), '' );
|
||||
deepEqual( window.url( '?poo', 'http://domain.com?' ), null );
|
||||
deepEqual( window.url( '?poo', 'http://domain.com' ), null );
|
||||
|
||||
deepEqual( window.url( '?poo', 'http://domain.com?poo=a+b' ), 'a b' );
|
||||
deepEqual( window.url( '?poo', 'http://domain.com?poo=javascript%20decode%20uri%20%2B%20sign%20to%20space' ), 'javascript decode uri + sign to space' );
|
||||
|
||||
deepEqual( window.url( '?key', 'http://domain.com?key=value=va?key2=value' ), 'value=va');
|
||||
});
|
||||
|
||||
test('url fragment', function() {
|
||||
deepEqual( window.url( '#', url ), 'test=hash&chucky=cheese' );
|
||||
deepEqual( window.url( '#chucky', url ), 'cheese' );
|
||||
deepEqual( window.url( '#poo', url ), null );
|
||||
|
||||
deepEqual( window.url( '#poo', 'http://domain.com#poo=' ), '' );
|
||||
deepEqual( window.url( '#poo', 'http://domain.com/#poo' ), '' );
|
||||
deepEqual( window.url( '#poo', 'http://domain.com#poo' ), '' );
|
||||
deepEqual( window.url( '#poo', 'http://domain.com#' ), null );
|
||||
deepEqual( window.url( '#poo', 'http://domain.com' ), null );
|
||||
});
|
||||
|
||||
if (typeof jQuery !== 'undefined') {
|
||||
test('jQuery', function() {
|
||||
deepEqual( $.url( 'domain', url ), 'domain.com' );
|
||||
deepEqual( $.url( 'path', url ), '/path/index.html' );
|
||||
deepEqual( $.url( '?silly', url ), 'willy' );
|
||||
deepEqual( $.url( '#poo', url ), null );
|
||||
});
|
||||
}
|
||||
|
||||
}());
|
|
@ -0,0 +1 @@
|
|||
/*! js-url - v2.1.0 - 2016-01-16 */window.url=function(){function a(){return new RegExp(/(.*?)\.?([^\.]*?)\.?(com|net|org|biz|ws|in|me|co\.uk|co|org\.uk|ltd\.uk|plc\.uk|me\.uk|edu|mil|br\.com|cn\.com|eu\.com|hu\.com|no\.com|qc\.com|sa\.com|se\.com|se\.net|us\.com|uy\.com|ac|co\.ac|gv\.ac|or\.ac|ac\.ac|af|am|as|at|ac\.at|co\.at|gv\.at|or\.at|asn\.au|com\.au|edu\.au|org\.au|net\.au|id\.au|be|ac\.be|adm\.br|adv\.br|am\.br|arq\.br|art\.br|bio\.br|cng\.br|cnt\.br|com\.br|ecn\.br|eng\.br|esp\.br|etc\.br|eti\.br|fm\.br|fot\.br|fst\.br|g12\.br|gov\.br|ind\.br|inf\.br|jor\.br|lel\.br|med\.br|mil\.br|net\.br|nom\.br|ntr\.br|odo\.br|org\.br|ppg\.br|pro\.br|psc\.br|psi\.br|rec\.br|slg\.br|tmp\.br|tur\.br|tv\.br|vet\.br|zlg\.br|br|ab\.ca|bc\.ca|mb\.ca|nb\.ca|nf\.ca|ns\.ca|nt\.ca|on\.ca|pe\.ca|qc\.ca|sk\.ca|yk\.ca|ca|cc|ac\.cn|com\.cn|edu\.cn|gov\.cn|org\.cn|bj\.cn|sh\.cn|tj\.cn|cq\.cn|he\.cn|nm\.cn|ln\.cn|jl\.cn|hl\.cn|js\.cn|zj\.cn|ah\.cn|gd\.cn|gx\.cn|hi\.cn|sc\.cn|gz\.cn|yn\.cn|xz\.cn|sn\.cn|gs\.cn|qh\.cn|nx\.cn|xj\.cn|tw\.cn|hk\.cn|mo\.cn|cn|cx|cz|de|dk|fo|com\.ec|tm\.fr|com\.fr|asso\.fr|presse\.fr|fr|gf|gs|co\.il|net\.il|ac\.il|k12\.il|gov\.il|muni\.il|ac\.in|co\.in|org\.in|ernet\.in|gov\.in|net\.in|res\.in|is|it|ac\.jp|co\.jp|go\.jp|or\.jp|ne\.jp|ac\.kr|co\.kr|go\.kr|ne\.kr|nm\.kr|or\.kr|li|lt|lu|asso\.mc|tm\.mc|com\.mm|org\.mm|net\.mm|edu\.mm|gov\.mm|ms|nl|no|nu|pl|ro|org\.ro|store\.ro|tm\.ro|firm\.ro|www\.ro|arts\.ro|rec\.ro|info\.ro|nom\.ro|nt\.ro|se|si|com\.sg|org\.sg|net\.sg|gov\.sg|sk|st|tf|ac\.th|co\.th|go\.th|mi\.th|net\.th|or\.th|tm|to|com\.tr|edu\.tr|gov\.tr|k12\.tr|net\.tr|org\.tr|com\.tw|org\.tw|net\.tw|ac\.uk|uk\.com|uk\.net|gb\.com|gb\.net|vg|sh|kz|ch|info|ua|gov|name|pro|ie|hk|com\.hk|org\.hk|net\.hk|edu\.hk|us|tk|cd|by|ad|lv|eu\.lv|bz|es|jp|cl|ag|mobi|eu|co\.nz|org\.nz|net\.nz|maori\.nz|iwi\.nz|io|la|md|sc|sg|vc|tw|travel|my|se|tv|pt|com\.pt|edu\.pt|asia|fi|com\.ve|net\.ve|fi|org\.ve|web\.ve|info\.ve|co\.ve|tel|im|gr|ru|net\.ru|org\.ru|hr|com\.hr|ly|xyz)$/)}function b(a){return decodeURIComponent(a.replace(/\+/g," "))}function c(a,b){var c=a.charAt(0),d=b.split(c);return c===a?d:(a=parseInt(a.substring(1),10),d[0>a?d.length+a:a-1])}function d(a,c){var d=a.charAt(0),e=c.split("&"),f=[],g={},h=[],i=a.substring(1);for(var j in e)if(f=e[j].match(/(.*?)=(.*)/),f||(f=[e[j],e[j],""]),""!==f[1].replace(/\s/g,"")){if(f[2]=b(f[2]||""),i===f[1])return f[2];h=f[1].match(/(.*)\[([0-9]+)\]/),h?(g[h[1]]=g[h[1]]||[],g[h[1]][h[2]]=f[2]):g[f[1]]=f[2]}return d===a?g:g[i]}return function(b,e){var f,g={};if("tld?"===b)return a();if(e=e||window.location.toString(),!b)return e;if(b=b.toString(),f=e.match(/^mailto:([^\/].+)/))g.protocol="mailto",g.email=f[1];else{if((f=e.match(/(.*?)#(.*)/))&&(g.hash=f[2],e=f[1]),g.hash&&b.match(/^#/))return d(b,g.hash);if((f=e.match(/(.*?)\?(.*)/))&&(g.query=f[2],e=f[1]),g.query&&b.match(/^\?/))return d(b,g.query);if((f=e.match(/(.*?)\:?\/\/(.*)/))&&(g.protocol=f[1].toLowerCase(),e=f[2]),(f=e.match(/(.*?)(\/.*)/))&&(g.path=f[2],e=f[1]),g.path=(g.path||"").replace(/^([^\/])/,"/$1").replace(/\/$/,""),b.match(/^[\-0-9]+$/)&&(b=b.replace(/^([^\/])/,"/$1")),b.match(/^\//))return c(b,g.path.substring(1));if(f=c("/-1",g.path.substring(1)),f&&(f=f.match(/(.*?)\.(.*)/))&&(g.file=f[0],g.filename=f[1],g.fileext=f[2]),(f=e.match(/(.*)\:([0-9]+)$/))&&(g.port=f[2],e=f[1]),(f=e.match(/(.*?)@(.*)/))&&(g.auth=f[1],e=f[2]),g.auth&&(f=g.auth.match(/(.*)\:(.*)/),g.user=f?f[1]:g.auth,g.pass=f?f[2]:void 0),g.hostname=e.toLowerCase(),"."===b.charAt(0))return c(b,g.hostname);a()&&(f=g.hostname.match(a()),f&&(g.tld=f[3],g.domain=f[2]?f[2]+"."+f[3]:void 0,g.sub=f[1]||void 0)),g.port=g.port||("https"===g.protocol?"443":"80"),g.protocol=g.protocol||("443"===g.port?"https":"http")}return b in g?g[b]:"{}"===b?g:void 0}}(),"undefined"!=typeof jQuery&&jQuery.extend({url:function(a,b){return window.url(a,b)}});
|
|
@ -1,35 +0,0 @@
|
|||
{
|
||||
"name": "url",
|
||||
"title": "url jQuery Plugin",
|
||||
"description": "A simple, lightweight url parser for JavaScript (~1.6 Kb minified, ~0.6Kb gzipped).",
|
||||
"keywords": [
|
||||
"websanova",
|
||||
"url"
|
||||
],
|
||||
"version": "1.8.6",
|
||||
"author": {
|
||||
"name": "Websanova",
|
||||
"email": "rob@websanova.com",
|
||||
"url": "http://websanova.com"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "Websanova",
|
||||
"email": "rob@websanova.com",
|
||||
"url": "http://websanova.com"
|
||||
}
|
||||
],
|
||||
"licenses": [
|
||||
{
|
||||
"type": "MIT",
|
||||
"url": "https://github.com/websanova/js-url#license"
|
||||
}
|
||||
],
|
||||
"bugs": "https://github.com/websanova/js-url/issues",
|
||||
"homepage": "http://url.websanova.com",
|
||||
"docs": "https://github.com/websanova/js-url#url",
|
||||
"download": "https://github.com/websanova/js-url/tags",
|
||||
"dependencies": {
|
||||
"jquery": ">=1.5"
|
||||
}
|
||||
}
|
|
@ -1,81 +1,178 @@
|
|||
window.url = (function() {
|
||||
function isNumeric(arg) {
|
||||
return !isNaN(parseFloat(arg)) && isFinite(arg);
|
||||
|
||||
function _t() {
|
||||
return; new RegExp(/(.*?)\.?([^\.]*?)\.?(com|net|org|biz|ws|in|me|co\.uk|co|org\.uk|ltd\.uk|plc\.uk|me\.uk|edu|mil|br\.com|cn\.com|eu\.com|hu\.com|no\.com|qc\.com|sa\.com|se\.com|se\.net|us\.com|uy\.com|ac|co\.ac|gv\.ac|or\.ac|ac\.ac|af|am|as|at|ac\.at|co\.at|gv\.at|or\.at|asn\.au|com\.au|edu\.au|org\.au|net\.au|id\.au|be|ac\.be|adm\.br|adv\.br|am\.br|arq\.br|art\.br|bio\.br|cng\.br|cnt\.br|com\.br|ecn\.br|eng\.br|esp\.br|etc\.br|eti\.br|fm\.br|fot\.br|fst\.br|g12\.br|gov\.br|ind\.br|inf\.br|jor\.br|lel\.br|med\.br|mil\.br|net\.br|nom\.br|ntr\.br|odo\.br|org\.br|ppg\.br|pro\.br|psc\.br|psi\.br|rec\.br|slg\.br|tmp\.br|tur\.br|tv\.br|vet\.br|zlg\.br|br|ab\.ca|bc\.ca|mb\.ca|nb\.ca|nf\.ca|ns\.ca|nt\.ca|on\.ca|pe\.ca|qc\.ca|sk\.ca|yk\.ca|ca|cc|ac\.cn|com\.cn|edu\.cn|gov\.cn|org\.cn|bj\.cn|sh\.cn|tj\.cn|cq\.cn|he\.cn|nm\.cn|ln\.cn|jl\.cn|hl\.cn|js\.cn|zj\.cn|ah\.cn|gd\.cn|gx\.cn|hi\.cn|sc\.cn|gz\.cn|yn\.cn|xz\.cn|sn\.cn|gs\.cn|qh\.cn|nx\.cn|xj\.cn|tw\.cn|hk\.cn|mo\.cn|cn|cx|cz|de|dk|fo|com\.ec|tm\.fr|com\.fr|asso\.fr|presse\.fr|fr|gf|gs|co\.il|net\.il|ac\.il|k12\.il|gov\.il|muni\.il|ac\.in|co\.in|org\.in|ernet\.in|gov\.in|net\.in|res\.in|is|it|ac\.jp|co\.jp|go\.jp|or\.jp|ne\.jp|ac\.kr|co\.kr|go\.kr|ne\.kr|nm\.kr|or\.kr|li|lt|lu|asso\.mc|tm\.mc|com\.mm|org\.mm|net\.mm|edu\.mm|gov\.mm|ms|nl|no|nu|pl|ro|org\.ro|store\.ro|tm\.ro|firm\.ro|www\.ro|arts\.ro|rec\.ro|info\.ro|nom\.ro|nt\.ro|se|si|com\.sg|org\.sg|net\.sg|gov\.sg|sk|st|tf|ac\.th|co\.th|go\.th|mi\.th|net\.th|or\.th|tm|to|com\.tr|edu\.tr|gov\.tr|k12\.tr|net\.tr|org\.tr|com\.tw|org\.tw|net\.tw|ac\.uk|uk\.com|uk\.net|gb\.com|gb\.net|vg|sh|kz|ch|info|ua|gov|name|pro|ie|hk|com\.hk|org\.hk|net\.hk|edu\.hk|us|tk|cd|by|ad|lv|eu\.lv|bz|es|jp|cl|ag|mobi|eu|co\.nz|org\.nz|net\.nz|maori\.nz|iwi\.nz|io|la|md|sc|sg|vc|tw|travel|my|se|tv|pt|com\.pt|edu\.pt|asia|fi|com\.ve|net\.ve|fi|org\.ve|web\.ve|info\.ve|co\.ve|tel|im|gr|ru|net\.ru|org\.ru|hr|com\.hr|ly|xyz)$/);
|
||||
}
|
||||
|
||||
function decode(str) {
|
||||
return decodeURIComponent(str.replace(/\+/g, ' '));
|
||||
function _d(s) {
|
||||
return decodeURIComponent(s.replace(/\+/g, ' '));
|
||||
}
|
||||
|
||||
return function(arg, url) {
|
||||
var _ls = url || window.location.toString();
|
||||
|
||||
if (!arg) { return _ls; }
|
||||
else { arg = arg.toString(); }
|
||||
function _i(arg, str) {
|
||||
var sptr = arg.charAt(0),
|
||||
split = str.split(sptr);
|
||||
|
||||
if (_ls.substring(0,2) === '//') { _ls = 'http:' + _ls; }
|
||||
else if (_ls.split('://').length === 1) { _ls = 'http://' + _ls; }
|
||||
if (sptr === arg) { return split; }
|
||||
|
||||
url = _ls.split('/');
|
||||
var _l = {auth:''}, host = url[2].split('@');
|
||||
arg = parseInt(arg.substring(1), 10);
|
||||
|
||||
if (host.length === 1) { host = host[0].split(':'); }
|
||||
else { _l.auth = host[0]; host = host[1].split(':'); }
|
||||
return split[arg < 0 ? split.length + arg : arg - 1];
|
||||
}
|
||||
|
||||
_l.protocol=url[0];
|
||||
_l.hostname=host[0];
|
||||
_l.port=(host[1] || ((_l.protocol.split(':')[0].toLowerCase() === 'https') ? '443' : '80'));
|
||||
_l.pathname=( (url.length > 3 ? '/' : '') + url.slice(3, url.length).join('/').split('?')[0].split('#')[0]);
|
||||
var _p = _l.pathname;
|
||||
function _f(arg, str) {
|
||||
var sptr = arg.charAt(0),
|
||||
split = str.split('&'),
|
||||
field = [],
|
||||
params = {},
|
||||
tmp = [],
|
||||
arg2 = arg.substring(1);
|
||||
|
||||
if (_p.charAt(_p.length-1) === '/') { _p=_p.substring(0, _p.length-1); }
|
||||
var _h = _l.hostname, _hs = _h.split('.'), _ps = _p.split('/');
|
||||
for (var i in split) {
|
||||
field = split[i].match(/(.*?)=(.*)/);
|
||||
|
||||
if (arg === 'hostname') { return _h; }
|
||||
else if (arg === 'domain') {
|
||||
if (/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/.test(_h)) { return _h; }
|
||||
return _hs.slice(-2).join('.');
|
||||
}
|
||||
//else if (arg === 'tld') { return _hs.slice(-1).join('.'); }
|
||||
else if (arg === 'sub') { return _hs.slice(0, _hs.length - 2).join('.'); }
|
||||
else if (arg === 'port') { return _l.port; }
|
||||
else if (arg === 'protocol') { return _l.protocol.split(':')[0]; }
|
||||
else if (arg === 'auth') { return _l.auth; }
|
||||
else if (arg === 'user') { return _l.auth.split(':')[0]; }
|
||||
else if (arg === 'pass') { return _l.auth.split(':')[1] || ''; }
|
||||
else if (arg === 'path') { return _l.pathname; }
|
||||
else if (arg.charAt(0) === '.')
|
||||
{
|
||||
arg = arg.substring(1);
|
||||
if(isNumeric(arg)) {arg = parseInt(arg, 10); return _hs[arg < 0 ? _hs.length + arg : arg-1] || ''; }
|
||||
}
|
||||
else if (isNumeric(arg)) { arg = parseInt(arg, 10); return _ps[arg < 0 ? _ps.length + arg : arg] || ''; }
|
||||
else if (arg === 'file') { return _ps.slice(-1)[0]; }
|
||||
else if (arg === 'filename') { return _ps.slice(-1)[0].split('.')[0]; }
|
||||
else if (arg === 'fileext') { return _ps.slice(-1)[0].split('.')[1] || ''; }
|
||||
else if (arg.charAt(0) === '?' || arg.charAt(0) === '#')
|
||||
{
|
||||
var params = _ls, param = null;
|
||||
|
||||
if(arg.charAt(0) === '?') { params = (params.split('?')[1] || '').split('#')[0]; }
|
||||
else if(arg.charAt(0) === '#') { params = (params.split('#')[1] || ''); }
|
||||
|
||||
if(!arg.charAt(1)) { return (params ? decode(params) : params); }
|
||||
|
||||
arg = arg.substring(1);
|
||||
params = params.split('&');
|
||||
|
||||
for(var i=0,ii=params.length; i<ii; i++)
|
||||
{
|
||||
param = params[i].split(/(.*?)=(.*)/).filter(Boolean);
|
||||
|
||||
if(param[0] === arg) { return (param[1] ? decode(param[1]) : param[1]) || ''; }
|
||||
// TODO: regex should be able to handle this.
|
||||
if ( ! field) {
|
||||
field = [split[i], split[i], ''];
|
||||
}
|
||||
|
||||
return null;
|
||||
if (field[1].replace(/\s/g, '') !== '') {
|
||||
field[2] = _d(field[2] || '');
|
||||
|
||||
// If we have a match just return it right away.
|
||||
if (arg2 === field[1]) { return field[2]; }
|
||||
|
||||
// Check for array pattern.
|
||||
tmp = field[1].match(/(.*)\[([0-9]+)\]/);
|
||||
|
||||
if (tmp) {
|
||||
params[tmp[1]] = params[tmp[1]] || [];
|
||||
|
||||
params[tmp[1]][tmp[2]] = field[2];
|
||||
}
|
||||
else {
|
||||
params[field[1]] = field[2];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
if (sptr === arg) { return params; }
|
||||
|
||||
return params[arg2];
|
||||
}
|
||||
|
||||
return function(arg, url) {
|
||||
var _l = {}, tmp, tmp2;
|
||||
|
||||
if (arg === 'tld?') { return _t(); }
|
||||
|
||||
url = url || window.location.toString();
|
||||
|
||||
if ( ! arg) { return url; }
|
||||
|
||||
arg = arg.toString();
|
||||
|
||||
if (tmp = url.match(/^mailto:([^\/].+)/)) {
|
||||
_l.protocol = 'mailto';
|
||||
_l.email = tmp[1];
|
||||
}
|
||||
else {
|
||||
|
||||
// Hash.
|
||||
if (tmp = url.match(/(.*?)#(.*)/)) {
|
||||
_l.hash = tmp[2];
|
||||
url = tmp[1];
|
||||
}
|
||||
|
||||
// Return hash parts.
|
||||
if (_l.hash && arg.match(/^#/)) { return _f(arg, _l.hash); }
|
||||
|
||||
// Query
|
||||
if (tmp = url.match(/(.*?)\?(.*)/)) {
|
||||
_l.query = tmp[2];
|
||||
url = tmp[1];
|
||||
}
|
||||
|
||||
// Return query parts.
|
||||
if (_l.query && arg.match(/^\?/)) { return _f(arg, _l.query); }
|
||||
|
||||
// Protocol.
|
||||
if (tmp = url.match(/(.*?)\:?\/\/(.*)/)) {
|
||||
_l.protocol = tmp[1].toLowerCase();
|
||||
url = tmp[2];
|
||||
}
|
||||
|
||||
// Path.
|
||||
if (tmp = url.match(/(.*?)(\/.*)/)) {
|
||||
_l.path = tmp[2];
|
||||
url = tmp[1];
|
||||
}
|
||||
|
||||
// Clean up path.
|
||||
_l.path = (_l.path || '').replace(/^([^\/])/, '/$1').replace(/\/$/, '');
|
||||
|
||||
// Return path parts.
|
||||
if (arg.match(/^[\-0-9]+$/)) { arg = arg.replace(/^([^\/])/, '/$1'); }
|
||||
if (arg.match(/^\//)) { return _i(arg, _l.path.substring(1)); }
|
||||
|
||||
// File.
|
||||
tmp = _i('/-1', _l.path.substring(1));
|
||||
|
||||
if (tmp && (tmp = tmp.match(/(.*?)\.(.*)/))) {
|
||||
_l.file = tmp[0];
|
||||
_l.filename = tmp[1];
|
||||
_l.fileext = tmp[2];
|
||||
}
|
||||
|
||||
// Port.
|
||||
if (tmp = url.match(/(.*)\:([0-9]+)$/)) {
|
||||
_l.port = tmp[2];
|
||||
url = tmp[1];
|
||||
}
|
||||
|
||||
// Auth.
|
||||
if (tmp = url.match(/(.*?)@(.*)/)) {
|
||||
_l.auth = tmp[1];
|
||||
url = tmp[2];
|
||||
}
|
||||
|
||||
// User and pass.
|
||||
if (_l.auth) {
|
||||
tmp = _l.auth.match(/(.*)\:(.*)/);
|
||||
|
||||
_l.user = tmp ? tmp[1] : _l.auth;
|
||||
_l.pass = tmp ? tmp[2] : undefined;
|
||||
}
|
||||
|
||||
// Hostname.
|
||||
_l.hostname = url.toLowerCase();
|
||||
|
||||
// Return hostname parts.
|
||||
if (arg.charAt(0) === '.') { return _i(arg, _l.hostname); }
|
||||
|
||||
// Domain, tld and sub domain.
|
||||
if (_t()) {
|
||||
tmp = _l.hostname.match(_t());
|
||||
|
||||
if (tmp) {
|
||||
_l.tld = tmp[3];
|
||||
_l.domain = tmp[2] ? tmp[2] + '.' + tmp[3] : undefined;
|
||||
_l.sub = tmp[1] || undefined;
|
||||
}
|
||||
}
|
||||
|
||||
// Set port and protocol defaults if not set.
|
||||
_l.port = _l.port || (_l.protocol === 'https' ? '443' : '80');
|
||||
_l.protocol = _l.protocol || (_l.port === '443' ? 'https' : 'http');
|
||||
}
|
||||
|
||||
// Return arg.
|
||||
if (arg in _l) { return _l[arg]; }
|
||||
|
||||
// Return everything.
|
||||
if (arg === '{}') { return _l; }
|
||||
|
||||
// Default to undefined for no match.
|
||||
return undefined;
|
||||
};
|
||||
})();
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
/*! url - v1.8.6 - 2015-08-21 */window.url=function(){function a(a){return!isNaN(parseFloat(a))&&isFinite(a)}function b(a){return decodeURIComponent(a.replace(/\+/g," "))}return function(c,d){var e=d||window.location.toString();if(!c)return e;c=c.toString(),"//"===e.substring(0,2)?e="http:"+e:1===e.split("://").length&&(e="http://"+e),d=e.split("/");var f={auth:""},g=d[2].split("@");1===g.length?g=g[0].split(":"):(f.auth=g[0],g=g[1].split(":")),f.protocol=d[0],f.hostname=g[0],f.port=g[1]||("https"===f.protocol.split(":")[0].toLowerCase()?"443":"80"),f.pathname=(d.length>3?"/":"")+d.slice(3,d.length).join("/").split("?")[0].split("#")[0];var h=f.pathname;"/"===h.charAt(h.length-1)&&(h=h.substring(0,h.length-1));var i=f.hostname,j=i.split("."),k=h.split("/");if("hostname"===c)return i;if("domain"===c)return/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/.test(i)?i:j.slice(-2).join(".");if("sub"===c)return j.slice(0,j.length-2).join(".");if("port"===c)return f.port;if("protocol"===c)return f.protocol.split(":")[0];if("auth"===c)return f.auth;if("user"===c)return f.auth.split(":")[0];if("pass"===c)return f.auth.split(":")[1]||"";if("path"===c)return f.pathname;if("."===c.charAt(0)){if(c=c.substring(1),a(c))return c=parseInt(c,10),j[0>c?j.length+c:c-1]||""}else{if(a(c))return c=parseInt(c,10),k[0>c?k.length+c:c]||"";if("file"===c)return k.slice(-1)[0];if("filename"===c)return k.slice(-1)[0].split(".")[0];if("fileext"===c)return k.slice(-1)[0].split(".")[1]||"";if("?"===c.charAt(0)||"#"===c.charAt(0)){var l=e,m=null;if("?"===c.charAt(0)?l=(l.split("?")[1]||"").split("#")[0]:"#"===c.charAt(0)&&(l=l.split("#")[1]||""),!c.charAt(1))return l?b(l):l;c=c.substring(1),l=l.split("&");for(var n=0,o=l.length;o>n;n++)if(m=l[n].split(/(.*?)=(.*)/).filter(Boolean),m[0]===c)return(m[1]?b(m[1]):m[1])||"";return null}}return""}}(),"undefined"!=typeof jQuery&&jQuery.extend({url:function(a,b){return window.url(a,b)}});
|
||||
/*! js-url - v2.1.0 - 2016-01-16 */window.url=function(){function a(){}function b(a){return decodeURIComponent(a.replace(/\+/g," "))}function c(a,b){var c=a.charAt(0),d=b.split(c);return c===a?d:(a=parseInt(a.substring(1),10),d[0>a?d.length+a:a-1])}function d(a,c){var d=a.charAt(0),e=c.split("&"),f=[],g={},h=[],i=a.substring(1);for(var j in e)if(f=e[j].match(/(.*?)=(.*)/),f||(f=[e[j],e[j],""]),""!==f[1].replace(/\s/g,"")){if(f[2]=b(f[2]||""),i===f[1])return f[2];h=f[1].match(/(.*)\[([0-9]+)\]/),h?(g[h[1]]=g[h[1]]||[],g[h[1]][h[2]]=f[2]):g[f[1]]=f[2]}return d===a?g:g[i]}return function(b,e){var f,g={};if("tld?"===b)return a();if(e=e||window.location.toString(),!b)return e;if(b=b.toString(),f=e.match(/^mailto:([^\/].+)/))g.protocol="mailto",g.email=f[1];else{if((f=e.match(/(.*?)#(.*)/))&&(g.hash=f[2],e=f[1]),g.hash&&b.match(/^#/))return d(b,g.hash);if((f=e.match(/(.*?)\?(.*)/))&&(g.query=f[2],e=f[1]),g.query&&b.match(/^\?/))return d(b,g.query);if((f=e.match(/(.*?)\:?\/\/(.*)/))&&(g.protocol=f[1].toLowerCase(),e=f[2]),(f=e.match(/(.*?)(\/.*)/))&&(g.path=f[2],e=f[1]),g.path=(g.path||"").replace(/^([^\/])/,"/$1").replace(/\/$/,""),b.match(/^[\-0-9]+$/)&&(b=b.replace(/^([^\/])/,"/$1")),b.match(/^\//))return c(b,g.path.substring(1));if(f=c("/-1",g.path.substring(1)),f&&(f=f.match(/(.*?)\.(.*)/))&&(g.file=f[0],g.filename=f[1],g.fileext=f[2]),(f=e.match(/(.*)\:([0-9]+)$/))&&(g.port=f[2],e=f[1]),(f=e.match(/(.*?)@(.*)/))&&(g.auth=f[1],e=f[2]),g.auth&&(f=g.auth.match(/(.*)\:(.*)/),g.user=f?f[1]:g.auth,g.pass=f?f[2]:void 0),g.hostname=e.toLowerCase(),"."===b.charAt(0))return c(b,g.hostname);a()&&(f=g.hostname.match(a()),f&&(g.tld=f[3],g.domain=f[2]?f[2]+"."+f[3]:void 0,g.sub=f[1]||void 0)),g.port=g.port||("https"===g.protocol?"443":"80"),g.protocol=g.protocol||("443"===g.port?"https":"http")}return b in g?g[b]:"{}"===b?g:void 0}}(),"undefined"!=typeof jQuery&&jQuery.extend({url:function(a,b){return window.url(a,b)}});
|
Загрузка…
Ссылка в новой задаче