mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-17 14:00:29 +01:00
Compare commits
4 Commits
v4.3.0-bet
...
protocol-v
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
494447741a | ||
|
|
7b174d25cb | ||
|
|
bbb03a08e9 | ||
|
|
b884b0be01 |
@@ -4,7 +4,7 @@
|
|||||||
if (typeof module === 'object' && module.exports) {
|
if (typeof module === 'object' && module.exports) {
|
||||||
var winston = require('winston');
|
var winston = require('winston');
|
||||||
|
|
||||||
module.exports = factory(require('xregexp'), winston);
|
module.exports = factory(require('xregexp'), winston, false);
|
||||||
module.exports.walk = function (dir, done) {
|
module.exports.walk = function (dir, done) {
|
||||||
// DEPRECATED
|
// DEPRECATED
|
||||||
var file = require('../../src/file');
|
var file = require('../../src/file');
|
||||||
@@ -21,10 +21,10 @@
|
|||||||
return (diff[0] * 1e3) + (diff[1] / 1e6);
|
return (diff[0] * 1e3) + (diff[1] / 1e6);
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
window.utils = factory(window.XRegExp, console);
|
window.utils = factory(window.XRegExp, console, true);
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
}(function (XRegExp, console) {
|
}(function (XRegExp, console, isBrowser) {
|
||||||
var freeze = Object.freeze || function (obj) { return obj; };
|
var freeze = Object.freeze || function (obj) { return obj; };
|
||||||
|
|
||||||
// add default escape function for escaping HTML entities
|
// add default escape function for escaping HTML entities
|
||||||
@@ -487,14 +487,50 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// https://github.com/sindresorhus/is-absolute-url
|
urlToLocation: function (url) {
|
||||||
isAbsoluteUrlRE: /^[a-zA-Z][a-zA-Z\d+\-.]*:/,
|
return utils.urlParse(url, true, true);
|
||||||
isWinPathRE: /^[a-zA-Z]:\\/,
|
},
|
||||||
isAbsoluteUrl: function (url) {
|
|
||||||
if (utils.isWinPathRE.test(url)) {
|
urlParse: function (url, parseQueryString, slashesDenoteHost) {
|
||||||
return false;
|
if (isBrowser) {
|
||||||
|
var a = document.createElement('a');
|
||||||
|
a.href = url;
|
||||||
|
return a;
|
||||||
}
|
}
|
||||||
return utils.isAbsoluteUrlRE.test(url);
|
return require('url').parse(url, parseQueryString, slashesDenoteHost);
|
||||||
|
},
|
||||||
|
|
||||||
|
isProtocolAbsoluteUrl: function (url) {
|
||||||
|
url = url.replace(/^\/{3,}/, '//');
|
||||||
|
var a = utils.urlParse(url, true, true);
|
||||||
|
if (isBrowser) {
|
||||||
|
return a.host !== window.location.host;
|
||||||
|
}
|
||||||
|
return !!a.host;
|
||||||
|
},
|
||||||
|
|
||||||
|
isProtocolRelativeUrl: function (url) {
|
||||||
|
return !utils.isProtocolAbsoluteUrl(url);
|
||||||
|
},
|
||||||
|
|
||||||
|
isSchemeAbsoluteUrl: function (url) {
|
||||||
|
var a = utils.urlParse(url);
|
||||||
|
if (isBrowser) {
|
||||||
|
return a.host !== window.location.host;
|
||||||
|
}
|
||||||
|
return !!a.host;
|
||||||
|
},
|
||||||
|
|
||||||
|
isSchemeRelativeUrl: function (url) {
|
||||||
|
return !utils.isSchemeAbsoluteUrl(url);
|
||||||
|
},
|
||||||
|
|
||||||
|
// scheme-absolute seems to win the people's consensus
|
||||||
|
// https://stackoverflow.com/questions/15581445/are-protocol-relative-urls-relative-urls
|
||||||
|
// BUT the behavior is different from the server and the client
|
||||||
|
// so we use isProtocolAbsoluteUrl()
|
||||||
|
isAbsoluteUrl: function (url) {
|
||||||
|
return utils.isProtocolAbsoluteUrl(url);
|
||||||
},
|
},
|
||||||
|
|
||||||
isRelativeUrl: function (url) {
|
isRelativeUrl: function (url) {
|
||||||
@@ -699,12 +735,6 @@
|
|||||||
return this.params()[key];
|
return this.params()[key];
|
||||||
},
|
},
|
||||||
|
|
||||||
urlToLocation: function (url) {
|
|
||||||
var a = document.createElement('a');
|
|
||||||
a.href = url;
|
|
||||||
return a;
|
|
||||||
},
|
|
||||||
|
|
||||||
// return boolean if string 'true' or string 'false', or if a parsable string which is a number
|
// return boolean if string 'true' or string 'false', or if a parsable string which is a number
|
||||||
// also supports JSON object and/or arrays parsing
|
// also supports JSON object and/or arrays parsing
|
||||||
toType: function (str) {
|
toType: function (str) {
|
||||||
|
|||||||
Reference in New Issue
Block a user