@8ms/helpers 1.3.23 → 1.3.25

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@8ms/helpers",
3
3
  "license": "UNLICENSED",
4
- "version": "1.3.23",
4
+ "version": "1.3.25",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
5
5
  * https://stackoverflow.com/a/196991/2664955
6
6
  */
7
7
  const getCapitalised = ({ input, split }) => {
8
- const splitToken = split || '_';
8
+ const regex = new RegExp(split || '_', 'g');
9
9
  return input
10
- .replace(`/${splitToken}/g`, ' ')
10
+ .replace(regex, ' ')
11
11
  .replace(/\w\S*/g, function (txt) {
12
12
  return txt.charAt(0)
13
13
  .toUpperCase() + txt.substr(1)
package/xml/getXml.js CHANGED
@@ -1,14 +1,21 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const get_1 = __importDefault(require("../axios/get"));
3
7
  const getXml = async ({ url }) => {
4
- const fetch = require('node-fetch');
5
- const response = await fetch(url);
6
- // Get the response as text (not JSON)
7
- let xml = await response.text();
8
- // Trim the contents
9
- xml = xml.trim();
10
- // Remove tabs, new lines, double spaces
11
- xml = xml.replace(/[ ]{2}|\r\n|\n|\r|\t/gm, '');
12
- return xml;
8
+ let response = '';
9
+ const apiResponse = await (0, get_1.default)({
10
+ url
11
+ });
12
+ if (apiResponse.isSuccess()) {
13
+ response = apiResponse.getBody().toString();
14
+ // Trim the contents
15
+ response = response.trim();
16
+ // Remove tabs, new lines, double spaces
17
+ response = response.replace(/[ ]{2}|\r\n|\n|\r|\t/gm, '');
18
+ }
19
+ return response;
13
20
  };
14
21
  exports.default = getXml;