fixUrl() properly handles search and hash parts.
This commit is contained in:
@@ -74,17 +74,19 @@ function fibonacci(start) {
|
||||
//====================================================================
|
||||
|
||||
// Fix URL if necessary.
|
||||
var URL_RE = /^(?:(?:http|ws)(s)?:\/\/)?(.*?)\/*(?:\/api\/)?$/;
|
||||
var URL_RE = /^(?:(?:http|ws)(s)?:\/\/)?(.*?)\/*(?:\/api\/)?(\?.*?)?(?:#.*)?$/;
|
||||
function fixUrl(url) {
|
||||
var matches = URL_RE.exec(url);
|
||||
var isSecure = !!matches[1];
|
||||
var rest = matches[2];
|
||||
var hostAndPath = matches[2];
|
||||
var search = matches[3];
|
||||
|
||||
return [
|
||||
isSecure ? 'wss' : 'ws',
|
||||
'://',
|
||||
rest,
|
||||
hostAndPath,
|
||||
'/api/',
|
||||
search,
|
||||
].join('');
|
||||
}
|
||||
exports.fixUrl = fixUrl;
|
||||
|
||||
Reference in New Issue
Block a user