|
1 |
| -/** |
2 |
| - * PostProcess |
3 |
| - * |
4 |
| - * @param {Object[]} parsedFiles |
5 |
| - * @param {String[]} filenames |
6 |
| - * @param {Object[]} preProcess |
7 |
| - * @param {Object} packageInfos |
8 |
| - */ |
9 |
| -function postProcess(parsedFiles, filenames, preProcess, packageInfos) { |
10 |
| - var targetName = 'sampleRequest'; |
11 |
| - |
12 |
| - parsedFiles.forEach(function(parsedFile) { |
13 |
| - parsedFile.forEach(function(block) { |
14 |
| - if (block.local[targetName]) { |
15 |
| - var newBlock = []; |
16 |
| - block.local[targetName].forEach(function(entry) { |
17 |
| - if (entry.url !== 'off') { |
18 |
| - // Check if is an internal url |
19 |
| - if (packageInfos.sampleUrl && entry.url.length >= 4 && entry.url.substr(0, 4).toLowerCase() !== 'http') { |
20 |
| - // Prepend sampleUrl |
21 |
| - entry.url = packageInfos.sampleUrl + entry.url; |
22 |
| - } |
23 |
| - newBlock.push(entry); |
24 |
| - } |
25 |
| - }); // forEach |
26 |
| - |
27 |
| - if (newBlock.length === 0) |
28 |
| - delete block.local[targetName]; |
29 |
| - else |
30 |
| - block.local[targetName] = newBlock; |
31 |
| - } else { |
32 |
| - if (packageInfos.sampleUrl && block.local && block.local.url) { |
33 |
| - block.local[targetName] = [{ |
34 |
| - 'url': packageInfos.sampleUrl + block.local.url |
35 |
| - }]; |
36 |
| - } |
37 |
| - } |
38 |
| - }); |
39 |
| - }); |
40 |
| -} |
41 |
| - |
42 |
| -/** |
43 |
| - * Exports |
44 |
| - */ |
45 |
| -module.exports = { |
46 |
| - postProcess: postProcess |
47 |
| -}; |
| 1 | +/** |
| 2 | + * PostProcess |
| 3 | + * |
| 4 | + * @param {Object[]} parsedFiles |
| 5 | + * @param {String[]} filenames |
| 6 | + * @param {Object[]} preProcess |
| 7 | + * @param {Object} packageInfos |
| 8 | + */ |
| 9 | +function postProcess(parsedFiles, filenames, preProcess, packageInfos) { |
| 10 | + var targetName = 'sampleRequest'; |
| 11 | + |
| 12 | + parsedFiles.forEach(function(parsedFile) { |
| 13 | + parsedFile.forEach(function(block) { |
| 14 | + if (block.local[targetName]) { |
| 15 | + var newBlock = []; |
| 16 | + block.local[targetName].forEach(function(entry) { |
| 17 | + if (entry.url !== 'off') { |
| 18 | + // Check if is an internal url |
| 19 | + if (packageInfos.sampleUrl && entry.url.length >= 4 && entry.url.substr(0, 4).toLowerCase() !== 'http') { |
| 20 | + // Prepend sampleUrl |
| 21 | + entry.url = packageInfos.sampleUrl + entry.url; |
| 22 | + } |
| 23 | + newBlock.push(entry); |
| 24 | + } |
| 25 | + }); // forEach |
| 26 | + |
| 27 | + if (newBlock.length === 0) |
| 28 | + delete block.local[targetName]; |
| 29 | + else |
| 30 | + block.local[targetName] = newBlock; |
| 31 | + } else { |
| 32 | + var url; |
| 33 | + if (packageInfos.sampleUrl && block.local && block.local.url) { |
| 34 | + // if the block local url is absolute, just use this don't append to the sampleUrl |
| 35 | + if (block.local.url.length >= 4 && block.local.url.substr(0, 4).toLowerCase() !== 'http') { |
| 36 | + url = packageInfos.sampleUrl + block.local.url; |
| 37 | + } else { |
| 38 | + url = block.local.url |
| 39 | + } |
| 40 | + |
| 41 | + block.local[targetName] = [{ |
| 42 | + 'url': url |
| 43 | + }]; |
| 44 | + } |
| 45 | + } |
| 46 | + }); |
| 47 | + }); |
| 48 | +} |
| 49 | + |
| 50 | +/** |
| 51 | + * Exports |
| 52 | + */ |
| 53 | +module.exports = { |
| 54 | + postProcess: postProcess |
| 55 | +}; |
0 commit comments