mirror of
https://github.com/documize/community.git
synced 2025-08-01 19:45:24 +02:00
Improved MS Word document name extraction
Use document filename and not H1 title inside document. Supports both Linux & MSFT.
This commit is contained in:
parent
f3e66b73c1
commit
7f2d2c01a6
2 changed files with 79 additions and 4 deletions
53
domain/conversion/conversion_test.go
Normal file
53
domain/conversion/conversion_test.go
Normal file
|
@ -0,0 +1,53 @@
|
|||
package conversion
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestFilename validates filename extraction from path
|
||||
func TestFilename(t *testing.T) {
|
||||
fn := "/var/folders/vx/lyhy36cn5kl994qj0pt6hgb80000gp/T/documize/_uploads/970f9d07-9bea-48a2-4333-b3c50bca42cd/Demo.docx"
|
||||
t.Run("Test filename "+fn, func(t *testing.T) {
|
||||
f := GetDocumentNameFromFilename(fn)
|
||||
if f != "Demo" {
|
||||
t.Error("Expected Demo, got " + f)
|
||||
}
|
||||
t.Log(f)
|
||||
})
|
||||
|
||||
fn = "/var/Demo Docs.docx"
|
||||
t.Run("Test filename "+fn, func(t *testing.T) {
|
||||
f := GetDocumentNameFromFilename(fn)
|
||||
if f != "Demo Docs" {
|
||||
t.Error("Expected Demo Docs, got " + f)
|
||||
}
|
||||
t.Log(f)
|
||||
})
|
||||
|
||||
fn = "Demo Docs.docx"
|
||||
t.Run("Test filename "+fn, func(t *testing.T) {
|
||||
f := GetDocumentNameFromFilename(fn)
|
||||
if f != "Demo Docs" {
|
||||
t.Error("Expected Demo Docs, got " + f)
|
||||
}
|
||||
t.Log(f)
|
||||
})
|
||||
|
||||
fn = "/DemoDocs.docx"
|
||||
t.Run("Test filename "+fn, func(t *testing.T) {
|
||||
f := GetDocumentNameFromFilename(fn)
|
||||
if f != "DemoDocs" {
|
||||
t.Error("Expected DemoDocs, got " + f)
|
||||
}
|
||||
t.Log(f)
|
||||
})
|
||||
|
||||
fn = "a\\b\\c\\DemoDocs.docx.ppt"
|
||||
t.Run("Test filename "+fn, func(t *testing.T) {
|
||||
f := GetDocumentNameFromFilename(fn)
|
||||
if f != "DemoDocs.docx" {
|
||||
t.Error("Expected DemoDocs.docx, got " + f)
|
||||
}
|
||||
t.Log(f)
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue