mod-build 3.6.88 → 3.6.89-beta.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.6.89
4
+
5
+ - Updated the `add-path-subdirectories` task to include path replacements for `../` or any variation of `../` in the src value.
6
+
3
7
  ## 3.6.88
4
8
 
5
9
  - Reverting the change made in `3.6.87` — need to regroup on a solve for our cache bust & it affecting JS parameters.
@@ -6,35 +6,25 @@ module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
6
6
  if (isPathSubdirectory) {
7
7
  const pathSubdirectory = isPathSubdirectory;
8
8
 
9
+ const replacePath = (match, path, attribute) => {
10
+ if (new RegExp(`^${attribute}="(\.\.\/)+`).test(path)) {
11
+ const subdirectoryLevels = (path.match(/\.\.\//g) || []).length;
12
+ const correctedPath = `${pathSubdirectory}${path.slice((attribute.length + 2) + 3 * subdirectoryLevels)}`;
13
+ return `${attribute}="${correctedPath}`;
14
+ } else {
15
+ return `${attribute}="${pathSubdirectory}${path.slice((attribute.length + 2))}`;
16
+ }
17
+ };
18
+
9
19
  return gulp.src(siteSettings.distFolder + '/**/*.html')
10
20
  .pipe(replace(/(href="favicon.ico")/g, function(match, path) {
11
21
  return `href="${pathSubdirectory}favicon.ico"`;
12
22
  }))
13
- .pipe(replace(/((src=")(resources|images|scripts|videos|shared-components|accessible-components)\/[^"]+")/g, function(match, path) {
14
- if (path.startsWith('src="resources') || path.startsWith('src="images') || path.startsWith('src="scripts') || path.startsWith('src="videos') || path.startsWith('src="shared-components') || path.startsWith('src="accessible-components')) {
15
- return `src="${pathSubdirectory}${path.slice(5)}`;
16
- }
17
- return match;
18
- }))
19
- .pipe(replace(/((srcset="images)\/[^"]+")/g, function(match, path) {
20
- if (path.startsWith('srcset="images')) {
21
- return `srcset="${pathSubdirectory}${path.slice(8)}`;
22
- }
23
- return match;
24
- }))
25
- .pipe(replace(/((poster="images)\/[^"]+")/g, function(match, path) {
26
- if (path.startsWith('poster="images')) {
27
- return `poster="${pathSubdirectory}${path.slice(8)}`;
28
- }
29
- return match;
30
- }))
31
- .pipe(replace(/((href=")(images|styles|shared-components|accessible-components)\/[^"]+")/g, function(match, path) {
32
- if (path.startsWith('href="images') || path.startsWith('href="styles') || path.startsWith('href="shared-components') || path.startsWith('src="accessible-components')) {
33
- return `href="${pathSubdirectory}${path.slice(6)}`;
34
- }
35
- return match;
36
- }))
23
+ .pipe(replace(/((src="(\.\.\/)*)(resources|images|scripts|videos|shared-components|accessible-components)\/[^"]+")/g, (match, path) => replacePath(match, path, 'src')))
24
+ .pipe(replace(/((srcset="(\.\.\/)*images)\/[^"]+")/g, (match, path) => replacePath(match, path, 'srcset')))
25
+ .pipe(replace(/((poster="(\.\.\/)*images)\/[^"]+")/g, (match, path) => replacePath(match, path, 'poster')))
26
+ .pipe(replace(/((href="(\.\.\/)*)(images|styles|shared-components|accessible-components)\/[^"]+")/g, (match, path) => replacePath(match, path, 'href')))
37
27
  .pipe(gulp.dest(siteSettings.distFolder));
38
28
  }
39
- }
29
+ };
40
30
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mod-build",
3
- "version": "3.6.88",
3
+ "version": "3.6.89-beta.2",
4
4
  "description": "Share components for S3 sites.",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",