mirror of
https://github.com/Karaka-Management/jsOMS.git
synced 2026-02-13 16:08:41 +00:00
First test implementation
This commit is contained in:
parent
0c0bae66a1
commit
972bcb83a5
|
|
@ -25,25 +25,35 @@
|
||||||
/**
|
/**
|
||||||
* Parse uri
|
* Parse uri
|
||||||
*
|
*
|
||||||
|
* @param {string} str Url to parse
|
||||||
|
* @param {string} mode Parsing mode
|
||||||
|
*
|
||||||
* @return {Object}
|
* @return {Object}
|
||||||
*
|
*
|
||||||
|
* @throws {Error}
|
||||||
|
*
|
||||||
* @function
|
* @function
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
*/
|
*/
|
||||||
jsOMS.Uri.UriFactory.parseUrl = function (str)
|
jsOMS.Uri.UriFactory.parseUrl = function (str, mode)
|
||||||
{
|
{
|
||||||
|
mode = typeof mode === 'undefined' ? 'php' : mode;
|
||||||
|
|
||||||
let query, key = ['source', 'scheme', 'authority', 'userInfo', 'user', 'pass', 'host', 'port',
|
let query, key = ['source', 'scheme', 'authority', 'userInfo', 'user', 'pass', 'host', 'port',
|
||||||
'relative', 'path', 'directory', 'file', 'query', 'fragment'
|
'relative', 'path', 'directory', 'file', 'query', 'fragment'
|
||||||
],
|
],
|
||||||
mode = 'php',
|
|
||||||
parser = {
|
parser = {
|
||||||
php: /^(?:([^:\/?#]+):)?(?:\/\/()(?:(?:()(?:([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?()(?:(()(?:(?:[^?#\/]*\/)*)()(?:[^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
|
php: /^(?:([^:\/?#]+):)?(?:\/\/()(?:(?:()(?:([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?()(?:(()(?:(?:[^?#\/]*\/)*)()(?:[^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
|
||||||
strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
|
strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
|
||||||
loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/\/?)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/ // Added one optional slash to post-scheme to catch file:/// (should restrict this)
|
loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/\/?)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/ // Added one optional slash to post-scheme to catch file:/// (should restrict this)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if(!parser.hasOwnProperty(mode)) {
|
||||||
|
throw new Error('Unexpected parsing mode.', 'UriFactory', 52);
|
||||||
|
}
|
||||||
|
|
||||||
let m = parser[mode].exec(str),
|
let m = parser[mode].exec(str),
|
||||||
uri = {},
|
uri = {},
|
||||||
i = 14;
|
i = 14;
|
||||||
|
|
@ -100,7 +110,7 @@
|
||||||
{
|
{
|
||||||
overwrite = typeof overwrite !== 'undefined' ? overwrite : true;
|
overwrite = typeof overwrite !== 'undefined' ? overwrite : true;
|
||||||
|
|
||||||
if (overwrite || !jsOMS.Uri.UriFactory.uri.hasProperty(key)) {
|
if (overwrite || !jsOMS.Uri.UriFactory.uri.hasOwnProperty(key)) {
|
||||||
jsOMS.Uri.UriFactory.uri[key] = value;
|
jsOMS.Uri.UriFactory.uri[key] = value;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user