Skip to content

Commit

Permalink
flow: page auto title ignores specified extension (#1203)
Browse files Browse the repository at this point in the history
  • Loading branch information
MykolaGolubyev authored May 1, 2024
1 parent 1605e75 commit b592102
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ private String buildHumanReadableName() {
return title.toString();
}

return NameUtils.dashToCamelCaseWithSpaces(givenName);
int dotIdx = givenName.indexOf('.');
String withoutExtension = dotIdx == -1 ? givenName : givenName.substring(0, dotIdx);
return NameUtils.dashToCamelCaseWithSpaces(withoutExtension);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ class TocItemTest {
tocItem.fileExtension.should == "mdx"
}

@Test
void "should create title from file name ignoring extension"() {
def tocItem = new TocItem('dir-name', 'file-name.mdx', 'md')
tocItem.dirName.should == "dir-name"
tocItem.fileNameWithoutExtension.should == "file-name"
tocItem.pageTitle.should == "File Name"
tocItem.fileExtension.should == "mdx"
}

@Test
void "should extract optional file name extension"() {
def tocItem = new TocItem('dir-name', 'file-name.mdx', 'md')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Fix: [auto title](flow/names) now correctly ignores specified extension.

0 comments on commit b592102

Please sign in to comment.