mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-12-05 16:15:41 -08:00
Trim comments and docs to what the code needs
AI Assisted
This commit is contained in:
1 parent
eba3c3bf0c
commit
0bd721fc27
33 files changed
+292
-392
No files matched your search
@@ -1,10 +1,8 @@
|
||||
// Web console tests, the page's URLs: every URL the page uses is page-relative.
|
||||
// The macOS app's frame gets no cookie, so it signs in by a path prefix
|
||||
// (`/f/<key>/`, routes.mjs) and the page is served under it there, while a
|
||||
// browser tab has it at `/`. A relative `state` reaches the server either
|
||||
// way; a slash-leading `/state` drops the prefix and gets a 403, in the macOS
|
||||
// app only, so no other test would notice. This guard reads the page's source
|
||||
// (and the links the server hands it) and names each slash-leading one.
|
||||
// The macOS app's frame signs in by a path prefix (`/f/<key>/`, routes.mjs) and
|
||||
// gets the page under it; a slash-leading `/state` drops the prefix and gets a
|
||||
// 403 there only, so no other test would notice. This reads the page's source,
|
||||
// and the links the server hands it, and names each slash-leading URL.
|
||||
// Run with: node --test scripts/test-web-console-relative-urls.mjs
|
||||
|
||||
import test from "node:test";
|
||||
@@ -43,19 +41,16 @@ function pageFiles(rel = "") {
|
||||
}
|
||||
|
||||
/**
|
||||
* Each string literal in `text` (double quotes, single quotes or backticks)
|
||||
* that makes a slash-leading URL, as `{ line, literal }`, in three shapes:
|
||||
* text opening with `/` and a path character (a letter, digit, `_`, `.`, `-`
|
||||
* or `${`); a lone `"/"` that starts an expression joined on with `+`
|
||||
* (`fetch("/" + route)`; one joined in the middle of a path is fine); and
|
||||
* markup in a string whose `src`, `href` or like attribute opens with `/`
|
||||
* (`` `<img src="/x">` ``). A comment line and anything after a `//` outside
|
||||
* a string are skipped; `//` opening a string is the protocol-relative case,
|
||||
* which render.js blocks on its own. Quotes are tracked one line at a time, so
|
||||
* a template literal that spans lines, or a regex literal holding a quote,
|
||||
* can put the scan out of step for the rest of that line: a URL there goes
|
||||
* unflagged, and only the frame page test, which loads the dashboard alone,
|
||||
* would catch it at run time.
|
||||
* Each string literal in `text` (any quote) that makes a slash-leading URL, as
|
||||
* `{ line, literal }`: text opening with `/` and a path character (a letter,
|
||||
* digit, `_`, `.`, `-` or `${`); a lone `"/"` starting an expression joined on
|
||||
* with `+` (`fetch("/" + route)`, not one mid-path); and markup whose `src`,
|
||||
* `href` or like attribute opens with `/`. Comment lines and anything after a
|
||||
* `//` outside a string are skipped; a string opening `//` is protocol-relative,
|
||||
* which render.js blocks itself. Quotes are tracked per line, so a template
|
||||
* literal spanning lines or a regex holding a quote can hide a URL for the rest
|
||||
* of that line; only the frame page test, which loads just the dashboard, could
|
||||
* catch it at run time.
|
||||
*/
|
||||
function scriptUrls(text) {
|
||||
const hits = [];
|
||||
|
||||
Reference in new issue
Block a user