[Pkg-javascript-commits] [sockjs-client] 251/350: Switch to url-parse module
tonnerre at ancient-solutions.com
tonnerre at ancient-solutions.com
Fri Aug 5 01:04:27 UTC 2016
This is an automated email from the git hooks/post-receive script.
tonnerre-guest pushed a commit to branch upstream
in repository sockjs-client.
commit c09340e81bf66e36a6891ae6606f7c1a2bc09ccc
Author: Bryce Kahle <bkahle at gmail.com>
Date: Wed Oct 29 12:12:30 2014 -0400
Switch to url-parse module
---
Makefile | 4 ++--
gulpfile.js | 4 ++--
lib/main.js | 8 ++++----
lib/transport/driver/xhr.js | 4 ++--
lib/utils/url.js | 4 ++--
package.json | 3 ++-
6 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/Makefile b/Makefile
index d8060b7..6f77250 100644
--- a/Makefile
+++ b/Makefile
@@ -2,14 +2,14 @@
testbundle:
@./node_modules/.bin/gulp testbundle
-test: testbundle
+test:
@if [ "x$(BROWSER_NAME)" = "x" ]; then make test-node; else make test-zuul; fi
test-node:
@./node_modules/.bin/mocha \
tests/node.js
-test-zuul:
+test-zuul: testbundle
@if [ "x$(BROWSER_PLATFORM)" = "x" ]; then \
./node_modules/.bin/zuul \
--browser-name $(BROWSER_NAME) \
diff --git a/gulpfile.js b/gulpfile.js
index 975e6de..bce5c4f 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -70,7 +70,7 @@ gulp.task('browserify', ['write-version'], function () {
return browserify(util._extend({
debug: true
}, browserifyOptions))
- .ignore('querystring')
+ .ignore('url')
.bundle()
.pipe(source('sockjs.js'))
.pipe(buffer())
@@ -83,7 +83,7 @@ gulp.task('browserify', ['write-version'], function () {
gulp.task('browserify:min', ['write-version'], function () {
return browserify(browserifyOptions)
- .ignore('querystring')
+ .ignore('url')
.exclude('debug')
.transform(envify({
NODE_ENV: 'production'
diff --git a/lib/main.js b/lib/main.js
index 0c3ff8b..4bcf9e4 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -2,7 +2,7 @@
require('./shims');
-var u = require('url')
+var parse = require('url-parse')
, inherits = require('inherits')
, JSON3 = require('json3')
, random = require('./utils/random')
@@ -49,7 +49,7 @@ function SockJS(url, protocols, options) {
this._server = options.server || random.numberString(1000);
// Step 1 of WS spec - parse and validate the url. Issue #8
- var parsedUrl = u.parse(url);
+ var parsedUrl = parse(url);
if (!parsedUrl.host || !parsedUrl.pathname || !parsedUrl.protocol) {
throw new SyntaxError("The URL '" + url + "' is invalid");
} else if (parsedUrl.hash) {
@@ -96,10 +96,10 @@ function SockJS(url, protocols, options) {
}
// remove the trailing slash
- parsedUrl.pathname = parsedUrl.pathname.replace(/[/]+$/, '');
+ parsedUrl.path = parsedUrl.pathname.replace(/[/]+$/, '') + (parsedUrl.search || '');
// store the sanitized url
- this.url = u.format(parsedUrl);
+ this.url = parsedUrl.protocol + '//' + parsedUrl.hostname + (parsedUrl.port ? (':' + parsedUrl.port) : '') + parsedUrl.path;
debug('using url', this.url);
// Step 7 - start connection in background
diff --git a/lib/transport/driver/xhr.js b/lib/transport/driver/xhr.js
index 7d716d3..2caf473 100644
--- a/lib/transport/driver/xhr.js
+++ b/lib/transport/driver/xhr.js
@@ -3,7 +3,7 @@
var EventEmitter = require('events').EventEmitter
, inherits = require('inherits')
, http = require('http')
- , u = require('url')
+ , parse = require('url-parse')
;
var debug = function() {};
@@ -16,7 +16,7 @@ function XhrDriver(method, url, payload, opts) {
var self = this;
EventEmitter.call(this);
- var parsedUrl = u.parse(url);
+ var parsedUrl = parse(url);
var options = {
method: method
, hostname: parsedUrl.hostname
diff --git a/lib/utils/url.js b/lib/utils/url.js
index 31e09cf..1634f04 100644
--- a/lib/utils/url.js
+++ b/lib/utils/url.js
@@ -1,6 +1,6 @@
'use strict';
-var u = require('url');
+var parse = require('url-parse');
var debug = function() {};
if (process.env.NODE_ENV !== 'production') {
@@ -13,7 +13,7 @@ module.exports = {
return null;
}
- var p = u.parse(url);
+ var p = parse(url);
if (p.protocol === 'file:') {
return null;
}
diff --git a/package.json b/package.json
index 3772f90..e27cffa 100644
--- a/package.json
+++ b/package.json
@@ -27,7 +27,8 @@
"eventsource": "^0.1.3",
"faye-websocket": "~0.7.3",
"inherits": "^2.0.1",
- "json3": "^3.3.2"
+ "json3": "^3.3.2",
+ "url-parse": "0.0.3"
},
"devDependencies": {
"browserify": "^6.1.0",
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/sockjs-client.git
More information about the Pkg-javascript-commits
mailing list