1use thiserror::Error;
7
8const LICENSE_URL: &str = "https://github.com/squigit-org/squigit/blob/main/LICENSE";
10const TERMS_OF_SERVICE_URL: &str = "https://squigit-org.github.io/legal/terms.html";
11const PRIVACY_POLICY_URL: &str = "https://squigit-org.github.io/legal/privacy.html";
12
13pub(crate) const SQUIGIT_RELEASES_URL: &str =
15 "https://raw.githubusercontent.com/squigit-org/distribution/main/releases.json";
16
17#[derive(Debug, Error)]
18pub enum UrlError {
19 #[error("Unknown Squigit URL identifier: {0}")]
20 UnknownIdentifier(String),
21}
22
23pub type Result<T> = std::result::Result<T, UrlError>;
24
25pub fn resolve(identifier: &str) -> Result<String> {
26 match identifier.trim() {
27 "license" => Ok(LICENSE_URL.to_string()),
28 "terms" => Ok(TERMS_OF_SERVICE_URL.to_string()),
29 "privacy" => Ok(PRIVACY_POLICY_URL.to_string()),
30 identifier => Err(UrlError::UnknownIdentifier(identifier.to_string())),
31 }
32}