{"record":{"id":"7a9cb52fedd15d33","repo":"Kuberwastaken/claurst","slug":"https-ftp-s-www-s","errorCode":null,"errorMessage":"(?:https?|ftp)://\\S+|www\\.\\S+","messagePattern":"\\(\\?:https\\?\\|ftp\\)://\\\\S\\+\\|www\\\\\\.\\\\S\\+","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"info","filePath":"src-rust/crates/commands/src/share.rs","lineNumber":145,"sourceCode":"        } else if opted_out {\r\n            \"The gist is secret (unlisted). Anyone with the link can view it; delete the gist to revoke access.\"\r\n        } else {\r\n            \"Could not auto-open the link. Copy the URL above. The gist is secret (unlisted); delete the gist to revoke access.\"\r\n        };\r\n\r\n        CommandResult::Message(format!(\r\n            \"Share URL: {viewer}\\nGist: {gist_url}\\n\\n{footer}\"\r\n        ))\r\n    }\r\n}\r\n\r\n// ---- /links --------------------------------------------------------------\r\n\r\n/// Detect URLs in plain text. Mirrors the styling regex in tui::messages::markdown\r\n/// so the user sees the same links the renderer highlights.\r\nfn links_url_regex() -> &'static regex::Regex {\r\n    static URL_RE: once_cell::sync::Lazy<regex::Regex> = once_cell::sync::Lazy::new(|| {\r\n        regex::Regex::new(r\"(?:https?|ftp)://\\S+|www\\.\\S+\").expect(\"links URL regex\")\r\n    });\r\n    &URL_RE\r\n}\r\n\r\nfn strip_trailing_punct(url: &str) -> String {\r\n    let mut s = url.to_string();\r\n    while let Some(c) = s.chars().last() {\r\n        if matches!(c, '.' | ',' | ';' | ':' | '!' | '?' | ')' | ']' | '}' | '\\'' | '\"' | '>') {\r\n            s.pop();\r\n        } else {\r\n            break;\r\n        }\r\n    }\r\n    s\r\n}\r\n\r\n/// Walk messages (oldest → newest), pulling text out of each block and\r\n/// returning unique URLs in *most-recent-first* order.\r","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/Kuberwastaken/claurst/blob/b0637c97ec34144387cbf2f74f65df6d16a6cef1/src-rust/crates/commands/src/share.rs#L127-L163","documentation":"This panic wraps construction of the static URL-detection regex used by the /links command: `regex::Regex::new(r\"(?:https?|ftp)://\\S+|www\\.\\S+\").expect(...)`. The pattern is a compile-time constant and is valid, so the expect should never fire; it exists because Regex::new returns a Result that must be handled inside the Lazy initializer.","triggerScenarios":"Practically unreachable: calling `links_url_regex()` (via `extract_session_urls`) only panics if the hard-coded regex string was edited into an invalid pattern, since the Lazy static is built on first use.","commonSituations":"A developer edits the URL pattern and introduces a syntax error (unbalanced group, bad escape); the panic then fires on the first /links invocation rather than at compile time.","solutions":["If this panic occurred, the pattern string in `links_url_regex` was modified — revert or fix the regex syntax.","Validate regex changes in a test (`Regex::new(PATTERN).unwrap()` in a unit test) so breakage is caught by `cargo test`, not at runtime.","Prefer `once_cell::sync::Lazy` with a checked pattern plus a debug_assert, or move validation to a compile-time check.","Keep the error message distinct (`\"links URL regex\"`) so the panicking constant is easy to locate."],"exampleFix":"// before\nstatic URL_RE: once_cell::sync::Lazy<regex::Regex> = once_cell::sync::Lazy::new(|| {\n    regex::Regex::new(r\"(?:https?|ftp)://\\S+|www\\.\\S+\").expect(\"links URL regex\")\n});\n// after (test guarding the constant)\n#[test]\nfn links_url_regex_is_valid() {\n    links_url_regex();\n}","handlingStrategy":"validation","validationCode":"// Compile-time-ish guard: unit test asserting the constant parses\n#[test]\nfn links_url_regex_compiles() {\n    regex::Regex::new(r\"(?:https?|ftp)://\\S+|www\\.\\S+\").unwrap();\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never edit the regex constant without running the regex-compiles unit test","Keep the descriptive expect message so the failing constant is identifiable","Validate regex syntax locally with `regex-cli` or a quick `Regex::new` snippet before committing"],"tags":["rust","regex","static-init","panic"],"backgroundTag":"invalid-regex-pattern","analyzedSha":"b0637c97ec34144387cbf2f74f65df6d16a6cef1","analyzedAt":"2026-09-10T00:24:58.650Z","contentChangedAt":"2026-09-10T00:24:58.650Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}