MCPcopy
hub / github.com/webpack/webpack / parseIcssImportRequest

Function parseIcssImportRequest

lib/css/CssParser.js:773–799  ·  view source on GitHub ↗
(second, rule, source)

Source from the content-addressed store, hash-verified

771 * @returns {{ request: string } | { errorPos: number }} the unquoted request, or the position for the parse warning
772 */
773const parseIcssImportRequest = (second, rule, source) => {
774 /** @type {AstNode[] | undefined} */
775 let args;
776 if (A.type(second) === NodeType.Function) {
777 args = A.children(second);
778 } else {
779 for (const p of A.prelude(rule)) {
780 if (A.type(p) === NodeType.SimpleBlock && A.blockToken(p) === "(") {
781 args = A.children(p);
782 break;
783 }
784 }
785 }
786 // The first non-whitespace value inside `(...)` must be a string.
787 const innerStrToken =
788 args && args.find((v) => A.type(v) !== NodeType.Whitespace);
789 if (!innerStrToken || A.type(innerStrToken) !== NodeType.String) {
790 const errorPos =
791 A.type(second) === NodeType.Function
792 ? A.nameEnd(second) + 1
793 : A.end(second);
794 return { errorPos };
795 }
796 return {
797 request: source.slice(A.start(innerStrToken) + 1, A.end(innerStrToken) - 1)
798 };
799};
800
801class CssParser extends Parser {
802 /**

Callers 1

processImportOrExportMethod · 0.85

Calls 2

sliceMethod · 0.80
typeMethod · 0.45

Tested by

no test coverage detected