This commit is contained in:
Jade (Rose) Rowland
2025-02-27 20:42:40 -05:00
parent 8867a843ac
commit b531962b1f
3 changed files with 6 additions and 9 deletions
+3 -2
View File
@@ -1,9 +1,10 @@
const ALLOW_MANY = ['by', 'url', 'genre', 'license'];
import { defaultCode } from './user_pattern_utils.mjs';
export function getMetadata(raw_code) {
if (raw_code == null) {
console.error('saved pattern is empty or corrupted')
raw_code = '';
console.error('could not extract metadata from missing pattern code');
raw_code = defaultCode;
}
const comment_regexp = /\/\*([\s\S]*?)\*\/|\/\/(.*)$/gm;
const comments = [...raw_code.matchAll(comment_regexp)].map((c) => (c[1] || c[2] || '').trim());