mirror of https://github.com/rwf2/Rocket.git
Use 'normpath' to fix canonicalization on Windows.
This commit is contained in:
parent
374ad8804c
commit
73037c6620
|
@ -13,7 +13,7 @@ edition = "2018"
|
|||
|
||||
[features]
|
||||
# Internal use only.
|
||||
templates = ["serde", "serde_json", "glob", "notify"]
|
||||
templates = ["serde", "serde_json", "glob", "notify", "normpath"]
|
||||
databases = [
|
||||
"serde", "r2d2", "tokio/rt", "tokio/rt-multi-thread",
|
||||
"rocket_contrib_codegen/database_attribute"
|
||||
|
@ -57,6 +57,7 @@ handlebars = { version = "3.0", optional = true }
|
|||
glob = { version = "0.3", optional = true }
|
||||
tera = { version = "1.0.2", optional = true }
|
||||
notify = { version = "4.0.6", optional = true }
|
||||
normpath = { version = "0.2", optional = true }
|
||||
|
||||
# UUID dependencies.
|
||||
uuid = { version = ">=0.7.0, <0.9.0", optional = true }
|
||||
|
|
|
@ -4,6 +4,7 @@ use std::collections::HashMap;
|
|||
use crate::templates::{Engines, TemplateInfo};
|
||||
|
||||
use rocket::http::ContentType;
|
||||
use normpath::PathExt;
|
||||
|
||||
pub(crate) struct Context {
|
||||
/// The root of the template directory.
|
||||
|
@ -19,8 +20,8 @@ impl Context {
|
|||
/// template engine, and store all of the initialized state in a `Context`
|
||||
/// structure, which is returned if all goes well.
|
||||
pub fn initialize(root: &Path) -> Option<Context> {
|
||||
let root = match root.canonicalize() {
|
||||
Ok(root) => root,
|
||||
let root = match root.normalize() {
|
||||
Ok(root) => root.into_path_buf(),
|
||||
Err(e) => {
|
||||
error!("Invalid template directory '{}': {}.", root.display(), e);
|
||||
return None;
|
||||
|
|
Loading…
Reference in New Issue