@cilix/lightjs 0.0.13 → 0.0.15
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/core.js +14 -1
- package/index.js +16 -2
- package/package.json +1 -1
package/core.js
CHANGED
|
@@ -397,7 +397,7 @@ module.exports = (config, fs, path) => {
|
|
|
397
397
|
let in_expr = false;
|
|
398
398
|
let pos = cursor;
|
|
399
399
|
while (i < max) {
|
|
400
|
-
if (text[i] === "{" && text[i+1] === "{" && in_expr === false) {
|
|
400
|
+
if (text[i] === "{" && text[i+1] === "{" && in_expr === false && text[i-1] !== '\\') {
|
|
401
401
|
in_expr = true;
|
|
402
402
|
chunks.push({ type: "chunk", data: chunk, pos: pos, file: file });
|
|
403
403
|
chunk = "{{";
|
|
@@ -589,8 +589,21 @@ module.exports = (config, fs, path) => {
|
|
|
589
589
|
});
|
|
590
590
|
}
|
|
591
591
|
text = lines.join('\n');
|
|
592
|
+
/* TODO - error reporting within an interpolation is
|
|
593
|
+
* bad (incorrect token position) due to newline magic above */
|
|
594
|
+
tokens.push({ type: 'string', pos: offs + cursor, file: file });
|
|
595
|
+
let chunks = break_into_chunks(text, cursor);
|
|
596
|
+
if (chunks.length > 1) {
|
|
597
|
+
chunks.forEach(function(c) {
|
|
598
|
+
tokens.push(c);
|
|
599
|
+
});
|
|
600
|
+
} else {
|
|
601
|
+
tokens.push({ type: 'chunk', data: text, pos: offs + cursor, file: file })
|
|
602
|
+
}
|
|
603
|
+
/*
|
|
592
604
|
tokens.push({ type: 'string', pos: offs + cursor, file: file });
|
|
593
605
|
tokens.push({ type: 'chunk', data: text, pos: offs + cursor, file: file })
|
|
606
|
+
*/
|
|
594
607
|
cursor = i;
|
|
595
608
|
continue;
|
|
596
609
|
} else if (c === '"' || c === "'") {
|
package/index.js
CHANGED
|
@@ -236,7 +236,14 @@ function matchRoute (istr, mstr) {
|
|
|
236
236
|
if (last[last.length - 1] !== '*') {
|
|
237
237
|
return null;
|
|
238
238
|
}
|
|
239
|
-
} else if (p0.length
|
|
239
|
+
} else if (p0.length === p1.length - 1) {
|
|
240
|
+
const last = p1[p1.length - 1];
|
|
241
|
+
if (last[last.length - 1] !== '?') {
|
|
242
|
+
return null;
|
|
243
|
+
}
|
|
244
|
+
} else if (p0.length !== p1.length) {
|
|
245
|
+
return null;
|
|
246
|
+
}
|
|
240
247
|
for (let i = 0; i < p1.length; i++) {
|
|
241
248
|
const p = p1[i];
|
|
242
249
|
if (p[0] !== ':') {
|
|
@@ -249,7 +256,13 @@ function matchRoute (istr, mstr) {
|
|
|
249
256
|
out[p.slice(1, -1)] += `/${p0[j]}`;
|
|
250
257
|
}
|
|
251
258
|
} else {
|
|
252
|
-
|
|
259
|
+
if (p[p.length - 1] === '?') {
|
|
260
|
+
if (p0[i]) {
|
|
261
|
+
out[p.slice(1, -1)] = p0[i];
|
|
262
|
+
}
|
|
263
|
+
} else {
|
|
264
|
+
out[p.slice(1)] = p0[i];
|
|
265
|
+
}
|
|
253
266
|
}
|
|
254
267
|
}
|
|
255
268
|
return out;
|
|
@@ -329,6 +342,7 @@ Light.router = function (opts) {
|
|
|
329
342
|
if (!matchedRoute) {
|
|
330
343
|
if (next) {
|
|
331
344
|
next();
|
|
345
|
+
return;
|
|
332
346
|
} else {
|
|
333
347
|
res.writeHead(404, { 'Content-type': 'text/html; charset=utf-8' });
|
|
334
348
|
res.end('<h1>404 - Not Found</h1>');
|