mirror of
https://github.com/azure/login.git
synced 2026-06-07 21:17:08 +00:00
* Bump lodash from 4.17.15 to 4.17.19 (#52) Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.19) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Amruta Kawade <65217380+AmrutaKawade@users.noreply.github.com> * Bump @actions/core from 1.1.3 to 1.2.6 (#60) Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 1.1.3 to 1.2.6. - [Release notes](https://github.com/actions/toolkit/releases) - [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md) - [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Amruta Kawade <65217380+AmrutaKawade@users.noreply.github.com> * updating node_nodules * updated package-lock Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
149 lines
3.6 KiB
JavaScript
149 lines
3.6 KiB
JavaScript
'use strict';
|
|
|
|
Object.defineProperty(exports, '__esModule', {
|
|
value: true
|
|
});
|
|
exports.dedentLines = void 0;
|
|
|
|
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
const getIndentationLength = line => {
|
|
const result = /^( {2})+/.exec(line);
|
|
return result === null ? 0 : result[0].length;
|
|
};
|
|
|
|
const dedentLine = line => line.slice(getIndentationLength(line)); // Return true if:
|
|
// "key": "value has multiple lines\n…
|
|
// "key has multiple lines\n…
|
|
|
|
const hasUnmatchedDoubleQuoteMarks = string => {
|
|
let n = 0;
|
|
let i = string.indexOf('"', 0);
|
|
|
|
while (i !== -1) {
|
|
if (i === 0 || string[i - 1] !== '\\') {
|
|
n += 1;
|
|
}
|
|
|
|
i = string.indexOf('"', i + 1);
|
|
}
|
|
|
|
return n % 2 !== 0;
|
|
};
|
|
|
|
const isFirstLineOfTag = line => /^( {2})*\</.test(line); // The length of the output array is the index of the next input line.
|
|
// Push dedented lines of start tag onto output and return true;
|
|
// otherwise return false because:
|
|
// * props include a multiline string (or text node, if props have markup)
|
|
// * start tag does not close
|
|
|
|
const dedentStartTag = (input, output) => {
|
|
let line = input[output.length];
|
|
output.push(dedentLine(line));
|
|
|
|
if (line.includes('>')) {
|
|
return true;
|
|
}
|
|
|
|
while (output.length < input.length) {
|
|
line = input[output.length];
|
|
|
|
if (hasUnmatchedDoubleQuoteMarks(line)) {
|
|
return false; // because props include a multiline string
|
|
} else if (isFirstLineOfTag(line)) {
|
|
// Recursion only if props have markup.
|
|
if (!dedentMarkup(input, output)) {
|
|
return false;
|
|
}
|
|
} else {
|
|
output.push(dedentLine(line));
|
|
|
|
if (line.includes('>')) {
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}; // Push dedented lines of markup onto output and return true;
|
|
// otherwise return false because:
|
|
// * props include a multiline string
|
|
// * text has more than one adjacent line
|
|
// * markup does not close
|
|
|
|
const dedentMarkup = (input, output) => {
|
|
let line = input[output.length];
|
|
|
|
if (!dedentStartTag(input, output)) {
|
|
return false;
|
|
}
|
|
|
|
if (input[output.length - 1].includes('/>')) {
|
|
return true;
|
|
}
|
|
|
|
let isText = false;
|
|
const stack = [];
|
|
stack.push(getIndentationLength(line));
|
|
|
|
while (stack.length > 0 && output.length < input.length) {
|
|
line = input[output.length];
|
|
|
|
if (isFirstLineOfTag(line)) {
|
|
if (line.includes('</')) {
|
|
output.push(dedentLine(line));
|
|
stack.pop();
|
|
} else {
|
|
if (!dedentStartTag(input, output)) {
|
|
return false;
|
|
}
|
|
|
|
if (!input[output.length - 1].includes('/>')) {
|
|
stack.push(getIndentationLength(line));
|
|
}
|
|
}
|
|
|
|
isText = false;
|
|
} else {
|
|
if (isText) {
|
|
return false; // because text has more than one adjacent line
|
|
}
|
|
|
|
const indentationLengthOfTag = stack[stack.length - 1];
|
|
output.push(line.slice(indentationLengthOfTag + 2));
|
|
isText = true;
|
|
}
|
|
}
|
|
|
|
return stack.length === 0;
|
|
}; // Return lines unindented by heuristic;
|
|
// otherwise return null because:
|
|
// * props include a multiline string
|
|
// * text has more than one adjacent line
|
|
// * markup does not close
|
|
|
|
const dedentLines = input => {
|
|
const output = [];
|
|
|
|
while (output.length < input.length) {
|
|
const line = input[output.length];
|
|
|
|
if (hasUnmatchedDoubleQuoteMarks(line)) {
|
|
return null;
|
|
} else if (isFirstLineOfTag(line)) {
|
|
if (!dedentMarkup(input, output)) {
|
|
return null;
|
|
}
|
|
} else {
|
|
output.push(dedentLine(line));
|
|
}
|
|
}
|
|
|
|
return output;
|
|
};
|
|
|
|
exports.dedentLines = dedentLines;
|