Skip to content

Commit 0abdeee

Browse files
Shywimbep
authored andcommitted
source: Normalize UniqueID between Windows & Linux
1 parent e2f8664 commit 0abdeee

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

‎source/file.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ func (sp SourceSpec) NewFile(relpath string) *File {
155155
}
156156

157157
f.section = helpers.GuessSection(f.Dir())
158-
f.uniqueID = helpers.Md5String(f.Path())
158+
f.uniqueID = helpers.Md5String(filepath.ToSlash(f.relpath))
159159

160160
return f
161161
}

‎source/file_test.go‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ func TestFileUniqueID(t *testing.T) {
3737
f4 := ss.NewFile(filepath.FromSlash("test2/index.md"))
3838

3939
assert.NotEqual(t, f3.UniqueID(), f4.UniqueID())
40+
41+
f5l := ss.NewFile("test3/index.md")
42+
f5w := ss.NewFile(filepath.FromSlash("test3/index.md"))
43+
44+
assert.Equal(t, f5l.UniqueID(), f5w.UniqueID())
4045
}
4146

4247
func TestFileString(t *testing.T) {

0 commit comments

Comments
 (0)