Skip to main content

squigit/
urls.rs

1// Copyright 2026 a7mddra
2// SPDX-License-Identifier: Apache-2.0
3
4//! Canonical public URLs shared by Squigit shells.
5
6use thiserror::Error;
7
8// Public policies served
9const 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
13// Shared release metadata served to all Squigit shells.
14pub(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}