File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed
Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -14,14 +14,17 @@ const headLines = [
1414
1515function splitName(name) {
1616 const mp = name.split('/');
17+ if (mp.length !== 3) {
18+ throw new Error(`Invalid name: ${name}`);
19+ }
1720 // Check for characters outside of a-zA-Z0-9-_.
18- const allowedChars = /[^ a-zA-Z0-9-_.]/g ;
21+ const allowedChars = /^[ a-zA-Z0-9-_.]+$/ ;
1922 for (let i = 1; i <= 2; i++) {
2023 if (!allowedChars.test(mp[i])) {
2124 throw new Error(`Invalid character in ${name}: ${mp[i]}`);
2225 }
2326 }
24- return [mp[0 ], mp[1 ]];
27+ return [mp[1 ], mp[2 ]];
2528}
2629
2730let modules = { [data.name]: data };
@@ -99,7 +102,11 @@ let firstLine = lines.indexOf("## Manifest Arguments");
99102let lastLine = -1;
100103if (firstLine !== -1) {
101104 let inTable = false;
105+ let otherSection = -1;
102106 for (let i = firstLine + 1; i < lines.length; i++) {
107+ if (otherSection === -1 && lines[i].startsWith("#")) {
108+ otherSection = i;
109+ }
103110 const isTable = lines[i].startsWith("|");
104111 if (inTable) {
105112 if (!isTable) {
@@ -111,7 +118,13 @@ if (firstLine !== -1) {
111118 }
112119 }
113120 if (lastLine === -1) {
114- lastLine = Math.min(lines.length - 1, firstLine + headLines.length - 1);
121+ // Use last section if exists
122+ if (otherSection !== -1) {
123+ lastLine = otherSection - 2;
124+ } else {
125+ // Use end of file
126+ lastLine = lines.length - 1;
127+ }
115128 }
116129}
117130
You can’t perform that action at this time.
0 commit comments