Pudu programming language
Menu
Package

@chrismichaelps / pudu-lang-mcp

Model Context Protocol server for Pudu language documentation and compiler tools

0.1.1Apache-2.01

InstallClose

Uri.pudu

Pudu22 lines857 B

GitHub ↗
1/** @Utils.Uri.Helper — file and resource URI conversion */2module PuduLangMcp.Utils.Uri34/// The prefix of every file URI.5const FILE_SCHEME: Str = "file://"67/// The `file://` URI of an absolute path.8export fn fileUri(path: Str) -> Str {9  FILE_SCHEME + path.replace("%", "%25").replace(" ", "%20").replace("#", "%23").replace("?", "%3F")10}1112/// The path a `file://` URI names, or `None` for any other scheme.13export fn pathOfFileUri(uri: Str) -> Option[Str] {14  if !uri.startsWith(FILE_SCHEME) { return None }15  Some(uri.drop(FILE_SCHEME.length()).replace("%20", " ").replace("%23", "#").replace("%3F", "?").replace("%25", "%"))16}1718/// The part of a URI after `scheme`, or `None` when it has another scheme.19export fn resourcePath(uri: Str, scheme: Str) -> Option[Str] {20  if uri.startsWith(scheme) { Some(uri.drop(scheme.length())) } else { None }21}22