ti2-tourplan 1.0.76 → 1.0.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +19 -8
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -84,6 +84,15 @@ class BuyerPlugin {
|
|
|
84
84
|
let data = Normalizer.stripEnclosingQuotes(
|
|
85
85
|
js2xmlparser.parse('Request', model, xmlOptions),
|
|
86
86
|
);
|
|
87
|
+
// NOTE: Forward slash is NOT an invalid XML character and hence js2xmlparser
|
|
88
|
+
// doesn't escape it, however TourPlan needs it to be escaped as '/'
|
|
89
|
+
// so we need to do it manually after js2xmlparser has done its thing
|
|
90
|
+
// we need to carefull here because we don't want to escape the forward slash
|
|
91
|
+
// when it's inside a tag, so we use a negative lookbehind and lookahead to
|
|
92
|
+
// ensure the forward slash is not inside a tag.
|
|
93
|
+
// In future if more such characters are found, we can use a more sophisticated
|
|
94
|
+
// approach to handle them
|
|
95
|
+
data = data.replace(/(?<!<)\/(?![^<]*>)/g, '/');
|
|
87
96
|
data = data.replace(xmlOptions.dtd.name, `Request SYSTEM "${xmlOptions.dtd.name}"`);
|
|
88
97
|
let replyObj;
|
|
89
98
|
let errorStr;
|
|
@@ -217,7 +226,11 @@ class BuyerPlugin {
|
|
|
217
226
|
};
|
|
218
227
|
if (p.salutation) EachPaxDetails.Title = this.escapeInvalidXmlChars(p.salutation);
|
|
219
228
|
if (p.dob) EachPaxDetails.DateOfBirth = p.dob;
|
|
220
|
-
|
|
229
|
+
// NOTE: TourPlan API doesn't accept age as empty string, i.e. empty XML tag <Age/>
|
|
230
|
+
// and trhows and error like - "1000 SCN System.InvalidOperationException: There is an
|
|
231
|
+
// error in XML document (29, 8). (Input string was not in a correct format.)"
|
|
232
|
+
// The solution is to NOT send the Age tag if it's empty
|
|
233
|
+
if (!R.isNil(p.age) && !Number.isNaN(p.age) && p.age) {
|
|
221
234
|
if (!(p.passengerType === 'Adult' && p.age === 0)) {
|
|
222
235
|
EachPaxDetails.Age = p.age;
|
|
223
236
|
}
|
|
@@ -225,7 +238,7 @@ class BuyerPlugin {
|
|
|
225
238
|
return EachPaxDetails;
|
|
226
239
|
});
|
|
227
240
|
}
|
|
228
|
-
RoomConfigs.RoomConfig[indexRoomConfig++] = EachRoomConfig
|
|
241
|
+
RoomConfigs.RoomConfig[indexRoomConfig++] = EachRoomConfig;
|
|
229
242
|
});
|
|
230
243
|
return RoomConfigs;
|
|
231
244
|
};
|
|
@@ -246,18 +259,16 @@ class BuyerPlugin {
|
|
|
246
259
|
const preprocessed = accentedChars.reduce((acc, [k, v]) => acc.replace(k, v), s);
|
|
247
260
|
return preprocessed.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
|
|
248
261
|
};
|
|
262
|
+
// NOTE: There is no need to sanitize the string for 5 characters (&, <, >, " and ')
|
|
263
|
+
// because js2xmlparser does that for us. Plus if we use sanitize before calling js2xmlparser
|
|
264
|
+
// js2xmlparser will escape & to '&' making it invalid XML
|
|
249
265
|
return convertAccentedChars(str)
|
|
250
266
|
.replace(/’/g, "'")
|
|
251
267
|
.replace(/‘/g, "'")
|
|
252
268
|
.replace(/“/g, '"')
|
|
253
269
|
.replace(/”/g, '"')
|
|
254
270
|
.replace(/–/g, '-')
|
|
255
|
-
.replace(
|
|
256
|
-
.replace(/</g, '<')
|
|
257
|
-
.replace(/>/g, '>')
|
|
258
|
-
.replace(/"/g, '"')
|
|
259
|
-
.replace(/'/g, ''')
|
|
260
|
-
.replace(BAD_XML_CHARS, '')
|
|
271
|
+
.replace(BAD_XML_CHARS, '');
|
|
261
272
|
};
|
|
262
273
|
|
|
263
274
|
this.cacheSettings = {
|