guesses the scheme of a url string. see UriScheme for more details.

import { assertEquals } from "jsr:@std/assert"

// aliasing our functions for brevity
const eq = assertEquals, fn = getUriScheme

eq(fn("C:/Users/me/path/to/file.txt"), "local")
eq(fn("~/path/to/file.txt"), "local")
eq(fn("/usr/me/path/to/file.txt"), "local")
eq(fn("path/to/file.txt"), "relative")
eq(fn("./path/to/file.txt"), "relative")
eq(fn("../path/to/file.txt"), "relative")
eq(fn("file:///c://users/me/path/to/file.txt"), "file")
eq(fn("file:///usr/me/path/to/file.txt"), "file")
eq(fn("jsr:@user/path/to/file"), "jsr")
eq(fn("jsr:/@user/path/to/file"), "jsr")
eq(fn("npm:lib/path/to/file"), "npm")
eq(fn("npm:/lib/path/to/file"), "npm")
eq(fn("npm:/@scope/lib/path/to/file"), "npm")
eq(fn("data:text/plain;charset=utf-8;base64,aGVsbG8="), "data")
eq(fn("blob:https://example.com/4800d2d8-a78c-4895-b68b-3690b69a0d6a"), "blob")
eq(fn("http://google.com/style.css"), "http")
eq(fn("https://google.com/style.css"), "https")