1pub const BASE_URL: &str = "https://rewordsai.app";
2
3pub fn home_url() -> &'static str {
4 BASE_URL
5}
6
7pub fn tool_url(slug: &str) -> String {
8 let clean = slug.trim_matches('/');
9 if clean.is_empty() {
10 BASE_URL.to_string()
11 } else {
12 format!("{BASE_URL}/{clean}")
13 }
14}
15
16pub fn tools_url() -> String { tool_url("tools") }
17pub fn edit_text_in_image_url() -> String { tool_url("edit-text-in-image") }
18pub fn replace_text_in_image_url() -> String { tool_url("replace-text-in-image") }
19pub fn remove_text_from_image_url() -> String { tool_url("remove-text-from-image") }
20pub fn photo_text_editor_url() -> String { tool_url("photo-text-editor") }
21pub fn translate_text_in_image_url() -> String { tool_url("translate-text-in-image") }
22
23#[cfg(test)]
24mod tests {
25 use super::*;
26
27 #[test]
28 fn builds_links() {
29 assert_eq!(home_url(), "https://rewordsai.app");
30 assert_eq!(tools_url(), "https://rewordsai.app/tools");
31 assert_eq!(edit_text_in_image_url(), "https://rewordsai.app/edit-text-in-image");
32 assert_eq!(replace_text_in_image_url(), "https://rewordsai.app/replace-text-in-image");
33 assert_eq!(remove_text_from_image_url(), "https://rewordsai.app/remove-text-from-image");
34 assert_eq!(photo_text_editor_url(), "https://rewordsai.app/photo-text-editor");
35 assert_eq!(translate_text_in_image_url(), "https://rewordsai.app/translate-text-in-image");
36 }
37}