ti2-tourplan 1.0.72 → 1.0.74
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 +32 -19
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -87,23 +87,24 @@ class BuyerPlugin {
|
|
|
87
87
|
data = data.replace(xmlOptions.dtd.name, `Request SYSTEM "${xmlOptions.dtd.name}"`);
|
|
88
88
|
let replyObj;
|
|
89
89
|
let errorStr;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
90
|
+
// can't use proxy because of the static IP thing, darn
|
|
91
|
+
// if (this.xmlProxyUrl) {
|
|
92
|
+
// // use pyfilematch xmlproxy
|
|
93
|
+
// try {
|
|
94
|
+
// replyObj = R.path(['data'], await axios({
|
|
95
|
+
// method: 'post',
|
|
96
|
+
// url: `${this.xmlProxyUrl}/xmlproxy`,
|
|
97
|
+
// data: {
|
|
98
|
+
// url: endpoint,
|
|
99
|
+
// data,
|
|
100
|
+
// headers: getHeaders({ length: `${data.length}` }),
|
|
101
|
+
// },
|
|
102
|
+
// }));
|
|
103
|
+
// } catch (err) {
|
|
104
|
+
// console.log('error in calling pyfilematch xmlproxy', err);
|
|
105
|
+
// errorStr = `error in calling pyfilematch xmlproxy: ${err}`;
|
|
106
|
+
// }
|
|
107
|
+
// }
|
|
107
108
|
if (!replyObj) {
|
|
108
109
|
// in case of error /xmlproxy, fallback to call tourplan directly
|
|
109
110
|
// and then use pyfilematch xml2json to parse the xml
|
|
@@ -231,8 +232,20 @@ class BuyerPlugin {
|
|
|
231
232
|
this.escapeInvalidXmlChars = str => {
|
|
232
233
|
if (!str) return '';
|
|
233
234
|
const convertAccentedChars = s => {
|
|
234
|
-
|
|
235
|
-
|
|
235
|
+
// according to TC-143, we will go through one mapping first
|
|
236
|
+
// for certain accented chars
|
|
237
|
+
const accentedChars = [
|
|
238
|
+
['Ä', 'Ae'],
|
|
239
|
+
['Ö', 'Oe'],
|
|
240
|
+
['Ü', 'Ue'],
|
|
241
|
+
['ä', 'ae'],
|
|
242
|
+
['ö', 'oe'],
|
|
243
|
+
['ü', 'ue'],
|
|
244
|
+
['ß', 'ss'],
|
|
245
|
+
];
|
|
246
|
+
const preprocessed = accentedChars.reduce((acc, [k, v]) => acc.replace(k, v), s);
|
|
247
|
+
return preprocessed.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
|
|
248
|
+
};
|
|
236
249
|
return convertAccentedChars(str)
|
|
237
250
|
.replace(/’/g, "'")
|
|
238
251
|
.replace(/‘/g, "'")
|