For a string that looks like a file name with an extension, like “index.html”, this returns the portion of the string before the last period. If the text contains no period, the entire text is returned.
$ ori "Origami.basename('test.html')"
test
$ ori "Origami.basename('test.x.y.z')"
test.x.y
$ ori "Origami.basename('test')"
test
This behaves slightly different from the Node.js basename command, which is available in Origami as path/basename
. The Node.js basename
command only strips the extension if the expected extension is provided as an argument:
$ ori "<node:path>.basename('foo.txt')"
foo.txt
$ ori "<node:path>.basename('foo.txt', '.txt')"
foo