@produtype/core 1.17.0 → 1.17.1
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/dist/utils/textSearch.js +19 -2
- package/package.json +1 -1
package/dist/utils/textSearch.js
CHANGED
|
@@ -45,13 +45,30 @@ const PATTERN_DECLARATION = /^(?:const\s+\w+(?:\s*:[^=]+)?\s*=\s*)?\/(?:[^/\\]|\
|
|
|
45
45
|
* and `"access-control-allow-origin"` are one string spelled three ways. A trailing
|
|
46
46
|
* comment is dropped first; Go puts the documentation link on the same line.
|
|
47
47
|
*/
|
|
48
|
+
/**
|
|
49
|
+
* A header name, in the shape the protocol writes them.
|
|
50
|
+
*
|
|
51
|
+
* Radarr shortens its constants — `public const string AllowOrigin =
|
|
52
|
+
* "Access-Control-Allow-Origin";` — so the two halves do not match and the
|
|
53
|
+
* spells-its-own-name test says nothing. It is the same table: five lines naming five
|
|
54
|
+
* headers, and the policy that matters is `builder.AllowAnyOrigin()` in `Startup.cs`,
|
|
55
|
+
* two files away.
|
|
56
|
+
*
|
|
57
|
+
* Hyphenated capitalised words are how HTTP writes a header and almost nothing else
|
|
58
|
+
* is written that way. It is required to be the whole value of a declaration, so a
|
|
59
|
+
* line that *sends* one — `res.setHeader('Access-Control-Allow-Origin', origin)` —
|
|
60
|
+
* has other arguments and is untouched.
|
|
61
|
+
*/
|
|
62
|
+
const HTTP_HEADER_NAME = /^[A-Z][A-Za-z0-9]*(?:-[A-Z][A-Za-z0-9]*)+$/;
|
|
48
63
|
function spellsItsOwnName(trimmed) {
|
|
49
64
|
const withoutComment = trimmed.replace(/\s*(\/\/|#).*$/, '').replace(/[,;]\s*$/, '');
|
|
50
|
-
const assignment = /^(?:const|let|var|final|static|
|
|
65
|
+
const assignment = /^(?:(?:public|private|protected|internal|export|const|let|var|final|static|readonly|string)\s+)*([A-Za-z_][\w.]*)\s*(?::\s*[\w<>[\].]+)?\s*=\s*(['"`])([^'"`]+)\2$/.exec(withoutComment);
|
|
51
66
|
if (!assignment)
|
|
52
67
|
return false;
|
|
53
68
|
const plain = (value) => value.toLowerCase().replace(/[-_.\s]/g, '');
|
|
54
|
-
|
|
69
|
+
const declared = /^\s*(?:public|private|protected|internal|export|const|let|var|final|static|readonly)\b/.test(withoutComment);
|
|
70
|
+
return plain(assignment[1]) === plain(assignment[3])
|
|
71
|
+
|| (declared && HTTP_HEADER_NAME.test(assignment[3]));
|
|
55
72
|
}
|
|
56
73
|
/**
|
|
57
74
|
* A name given a type, rather than a value.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@produtype/core",
|
|
3
|
-
"version": "1.17.
|
|
3
|
+
"version": "1.17.1",
|
|
4
4
|
"description": "Deterministic CLI and library that analyzes a web application repository and reports how far it is from production-ready for the kind of product it is meant to be.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|