INNER CODE UNIT · Rust

normalizes_base_url

TheWaWaR/simple-http-server · src/config.rs:563

    fn normalizes_base_url() {
        assert_eq!(normalize_base_url("/").unwrap(), "/");
        assert_eq!(normalize_base_url("prefix").unwrap(), "/prefix/");
        assert_eq!(normalize_base_url("/prefix").unwrap(), "/prefix/");
        assert_eq!(normalize_base_url("/prefix/").unwrap(), "/prefix/");
    }

    #[test]
    fn resolves_root_relative_try_file() {
        let root = make_temp_dir();
        let nested = root.join("assets");
        fs::create_dir_all(&nested).unwrap();
        let file = nested.join("404.html");
        fs::write(&file, "not found").unwrap();

        let resolved = resolve_try_file_path(&root, Path::new("assets/404.html")).unwrap();
        assert_eq!(resolved, fs::canonicalize(file).unwrap());

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…