• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

adobe / reactor-turbine / 26974271630

04 Jun 2026 07:23PM UTC coverage: 18.928% (-77.0%) from 95.912%
26974271630

Pull #201

github

web-flow
Merge 99f374fa8 into 4a42733a4
Pull Request #201: Platir 64071 update vulnerability chain

36 of 379 branches covered (9.5%)

Branch coverage included in aggregate %.

4 of 6 new or added lines in 1 file covered. (66.67%)

640 existing lines in 47 files now uncovered.

197 of 852 relevant lines covered (23.12%)

1.21 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

3.39
/src/createSettingsFileTransformer.js
1
/***************************************************************************************
2
 * (c) 2021 Adobe. All rights reserved.
3
 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
 * you may not use this file except in compliance with the License. You may obtain a copy
5
 * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
 *
7
 * Unless required by applicable law or agreed to in writing, software distributed under
8
 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
 * OF ANY KIND, either express or implied. See the License for the specific language
10
 * governing permissions and limitations under the License.
11
 ****************************************************************************************/
12

13
var { isPlainObject } = require('is-plain-object');
3✔
14

15
function isArrayReference(str) {
UNCOV
16
  return (
×
17
    typeof str === 'string' &&
×
18
    str.indexOf('[') !== -1 &&
19
    str.indexOf(']') !== -1
20
  );
21
}
22
function sanitizeArrayKey(pathStrSegment) {
UNCOV
23
  return pathStrSegment.substr(
×
24
    0,
25
    // the name goes up to the start of the array bracket: 'someArrayName[]'
26
    pathStrSegment.indexOf('[')
27
  );
28
}
29

30
/**
31
 * Recursive function to loop through settings and look for the setting to transform,
32
 * which is the final entry within the pathSegments array. Alters settings in-place.
33
 * @param {Array} pathSegments
34
 * @param {Object} settings
35
 * @param {Function} decorateWithDynamicHost
36
 */
37
function traverseIntoSettings(pathSegments, settings, decorateWithDynamicHost) {
38
  // nothing to do
UNCOV
39
  if (!pathSegments.length || !isPlainObject(settings)) {
×
UNCOV
40
    return;
×
41
  }
42

UNCOV
43
  var currentKey = pathSegments[0];
×
44

45
  // base case
UNCOV
46
  if (pathSegments.length === 1) {
×
UNCOV
47
    if (
×
48
      settings.hasOwnProperty(currentKey) &&
×
49
      typeof settings[currentKey] === 'string'
50
    ) {
UNCOV
51
      settings[currentKey] = decorateWithDynamicHost(settings[currentKey]);
×
52
    }
UNCOV
53
    return;
×
54
  }
55

56
  // still more work to do
UNCOV
57
  var remainingPathSegments = pathSegments.slice(1);
×
UNCOV
58
  if (isArrayReference(currentKey)) {
×
59
    // 'someArrayReference[]' --> 'someArrayReference'
UNCOV
60
    currentKey = sanitizeArrayKey(currentKey);
×
UNCOV
61
    var settingsValue = settings[currentKey];
×
UNCOV
62
    if (Array.isArray(settingsValue)) {
×
UNCOV
63
      settingsValue.forEach(function (arrayEntryObject) {
×
UNCOV
64
        return traverseIntoSettings(
×
65
          remainingPathSegments,
66
          arrayEntryObject,
67
          decorateWithDynamicHost
68
        );
69
      });
70
    }
71
  } else {
72
    // object case
UNCOV
73
    return traverseIntoSettings(
×
74
      remainingPathSegments,
75
      settings[currentKey],
76
      decorateWithDynamicHost
77
    );
78
  }
79
}
80

81
/**
82
 * Returns a function that when called will attempt to traverse the passed in
83
 * settings object to each file path and transform a relative URL to an absolute
84
 * URL.
85
 *
86
 * @param isDynamicEnforced
87
 * @param decorateWithDynamicHost
88
 * @returns {(function(*=, *=, *=): (*))|*}
89
 */
90
module.exports = function (isDynamicEnforced, decorateWithDynamicHost) {
3✔
UNCOV
91
  return function (settings, filePaths, moduleReferencePath) {
×
UNCOV
92
    if (
×
93
      !isDynamicEnforced ||
×
94
      !isPlainObject(settings) ||
95
      !Object.keys(settings).length ||
96
      !Array.isArray(filePaths) ||
97
      !filePaths.length
98
    ) {
UNCOV
99
      return settings;
×
100
    }
101

102
    // pull out the file paths by the module's reference path and loop over each urlPath
UNCOV
103
    filePaths.forEach(function (filePathString) {
×
104
      // The custom code action provides the ability to have the source code in the 'source'
105
      // variable or to have an external file. Therefore, this module has 2 behaviors.
106
      // It also does not provide a value of false for isExternal just as all other extensions
107
      // that use fileTransform do not provide an isExternal variable check. Therefore, we need
108
      // to treat Adobe's custom code action special, and don't augment the 'source' variable
109
      // if isExternal is not also present.
UNCOV
110
      var isAdobeCustomCodeAction = Boolean(
×
111
        moduleReferencePath != null &&
×
112
          /^core\/.*actions.*\/customCode\.js$/.test(moduleReferencePath)
113
      );
UNCOV
114
      if (
×
115
        isAdobeCustomCodeAction &&
×
116
        filePathString === 'source' &&
117
        !settings.isExternal
118
      ) {
UNCOV
119
        return;
×
120
      }
121

122
      // modify the object in place
UNCOV
123
      traverseIntoSettings(
×
124
        filePathString.split('.'),
125
        settings,
126
        decorateWithDynamicHost
127
      );
128
    });
129

UNCOV
130
    return settings;
×
131
  };
132
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc