From 5b037e3a0026b9d1b78effd724d0792786c4a58c Mon Sep 17 00:00:00 2001 From: Cmdr McDonald Date: Sun, 13 Nov 2016 17:04:57 +0000 Subject: [PATCH] Additional info if import fails --- src/app/Coriolis.jsx | 6 +++--- src/app/utils/UtilityFunctions.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/Coriolis.jsx b/src/app/Coriolis.jsx index 8f5ca1be..9a1c0855 100644 --- a/src/app/Coriolis.jsx +++ b/src/app/Coriolis.jsx @@ -78,11 +78,11 @@ export default class Coriolis extends React.Component { /** * Import a build directly - * @param r {Object} the route object + * @param {Object} r The current route */ _importBuild(r) { try { - // Need to decode and gunzip the data + // Need to decode and gunzip the data, then build the ship const data = zlib.gunzipSync(new Buffer(Utils.fromUrlSafe(r.params.data), 'base64')); const json = JSON.parse(data); const ship = CompanionApiUtils.shipFromJson(json); @@ -90,7 +90,7 @@ export default class Coriolis extends React.Component { r.params.code = ship.toString(); this._setPage(OutfittingPage, r); } catch (err) { - this.setState({ error: err }); + this._onError("Failed to import ship", r.path, 0, 0, err); } } diff --git a/src/app/utils/UtilityFunctions.js b/src/app/utils/UtilityFunctions.js index 7a389a59..e1db151b 100644 --- a/src/app/utils/UtilityFunctions.js +++ b/src/app/utils/UtilityFunctions.js @@ -65,7 +65,7 @@ export function shallowEqual(objA, objB) { * @return {string} the converted string */ export function toUrlSafe(data) { - return data.replace(/\\/g, '-').replace(/\+/g, '_'); + return data.replace(/\//g, '-').replace(/\+/g, '_'); } /**