andreypopp / reactify

[DEPRECATED] Browserify transform for JSX (superset of JavaScript used in React library by Facebook)
MIT License
690 stars 68 forks source link

String is not being escaped properly with harmony string interpolation feature. #43

Closed CodisRedding closed 9 years ago

CodisRedding commented 9 years ago

I was hoping to use the string interpolation features of harmony but I'm running into an error when using the flag --harmony with reactify.

I first run npm start an all is well. As soon as I hit the code in the module (listed below) I get the error shown here. I'm not sure if this is an issue with reactify or not.

error

Error: Invalid URI "http:/localhost:8002/login" {stack: (...), message: "Invalid URI "http:/localhost:8002/login""}

config file

{
  "server": {
    "uri": "http://localhost",
    "port": "8002"
  }
}

module

var config = require('../../config.json');
// ...

module.exports = {
  login: function(username, password) {
    request.post(path.join(`${config.server.uri}:${config.server.port}`, 'login'), {
        username: username,
        password: password
      }, function(err, httpRes, body) {
        if (err) {
          return console.error(err);
        }
        ServerActionCreators.receiveLoginResult(httpResp);
      }
    );
  }
};

package.json

{
scripts: {
    start: watchify -t [ reactify --harmony ] -o js/bundle.js -v -d . & http-server -p 8002,
    build: NODE_ENV=production browserify -t [ reactify --harmony ] . | uglifyjs -cm > js/bundle.min.js,
    test: jest
  }
}
andreypopp commented 9 years ago

I'm not sure this is issue with reactify, you can try to

console.log(`${config.server.uri}:${config.server.port}`)

and see the resulted string.

CodisRedding commented 9 years ago

@andreypopp sure enough that resulted in correct output "http://localhost:8002". I'm now 99% sure that I'm just using path.join() incorrectly. Thanks. I'm going to close this.