Skip to content

Commit d694bee

Browse files
nickpdemarcoHKalbasi
authored andcommitted
Check for path components rather than string literals for relative paths
1 parent 3905e36 commit d694bee

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

zngur-parser/src/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{fmt::Display, process::exit};
1+
use std::{fmt::Display, path::Component, process::exit};
22

33
use ariadne::{Color, Label, Report, ReportKind, sources};
44
use chumsky::prelude::*;
@@ -299,12 +299,13 @@ impl ProcessedItem<'_> {
299299
path.span,
300300
)
301301
}
302-
if !path.path.starts_with(".") && !path.path.starts_with("..") {
303-
create_and_emit_error(
302+
match path.path.components().next() {
303+
Some(Component::CurDir) | Some(Component::ParentDir) => {}
304+
_ => create_and_emit_error(
304305
ctx,
305306
"Module import is not supported. Use a relative path instead.",
306307
path.span,
307-
)
308+
),
308309
}
309310

310311
r.imports.push(Import(path.path));

0 commit comments

Comments
 (0)