@@ -2,7 +2,10 @@ import assert from "assert";
2
2
import { DateTime , DateTimeOptions , Duration , DurationLike , Interval , IntervalMaybeValid } from "luxon" ;
3
3
import { parse } from "path" ;
4
4
5
+ import { assertLuxonValidity } from "@/util/luxon-utils" ;
6
+
5
7
import { DateBasedCollection } from "./schema" ;
8
+ import { sanitizeFolder } from "./utils" ;
6
9
7
10
/**
8
11
* @see {@link https://github.com/liamcain/obsidian-periodic-notes }
@@ -45,14 +48,15 @@ export class PeriodicNotes extends DateBasedCollection {
45
48
) {
46
49
super ( ) ;
47
50
48
- folder = folder . trim ( ) . replace ( / \/ $ / , "" ) ; // Ensure trailing slashes are removed.
51
+ folder = sanitizeFolder ( folder ) ;
49
52
const intervalOffset = Duration . fromDurationLike ( intervalOffsetLike ) ;
50
53
const intervalDuration = Duration . fromDurationLike ( intervalDurationLike ) ;
51
54
52
55
assert ( folder . length > 0 , "folder must be non-empty" ) ;
53
56
assert ( dateFormat . length > 0 , "dateFormat must be non-empty" ) ;
54
- assert ( intervalOffset . isValid , "dateOffset must be valid" ) ;
55
- assert ( intervalDuration . isValid && intervalDuration . valueOf ( ) !== 0 , "intervalDuration must be non-zero" ) ;
57
+ assertLuxonValidity ( intervalDuration , "intervalDuration must be valid" ) ;
58
+ assert ( intervalDuration . valueOf ( ) !== 0 , "intervalDuration must be non-zero" ) ;
59
+ assertLuxonValidity ( intervalOffset , "intervalOffset must be valid" ) ;
56
60
57
61
this . folder = folder ;
58
62
this . dateFormat = dateFormat ;
0 commit comments