fix: fixing issue with files and folder with dots in them

This commit is contained in:
Kacper Kula 2025-01-27 09:57:39 +00:00
parent e9bee3d329
commit dfbb5367dc
8 changed files with 40 additions and 14 deletions

View file

@ -1,3 +1,6 @@
# 0.19.2 (2025-01-27)
Fixed issue with files and folders containing dots in them.
# 0.19.1 (2025-01-27)
Added logging for unprocessable data to help reporting.

View file

@ -1,7 +1,7 @@
{
"id": "sqlseal",
"name": "SQLSeal",
"version": "0.19.1",
"version": "0.19.2",
"minAppVersion": "0.15.0",
"description": "Use SQL in your notes to query your vault files and CSV content.",
"author": "hypersphere",

View file

@ -1,6 +1,6 @@
{
"name": "sqlseal",
"version": "0.19.1",
"version": "0.19.2",
"description": "A plugin for Obsidian that allows you to run SQL queries on your notes.",
"main": "main.js",
"scripts": {

View file

@ -5,18 +5,8 @@ import { MarkdownTableSyncStrategy } from "./MarkdownTableSyncStrategy";
import { JsonFileSyncStrategy } from "./JSONFileSyncStrategy";
import { ParserTableDefinition } from "./types";
import { TableDefinitionExternal } from "../repository/tableDefinitions";
import { getFileExtension } from "src/utils/extractExtension";
function getFileExtension(pathname: string): string | null {
// FIXME: splitting for now
return pathname.split('.')[1].toLowerCase()
// const url = new URL(pathname);
// const filePath = url.pathname;
// const fileName = path.basename(filePath);
// return path.extname(fileName);
}
const resolveFileStrategy = (filename: string) => {
const extension = getFileExtension(filename)

View file

@ -158,4 +158,22 @@ select * from x`
]
})
})
it('should properly parse query with dot in their name', () => {
const q = `table x = file(3.Resources/data/file.csv)
select * from x
`
expect(parseLanguage(q, '2025-01-01.md')).toEqual({
queryPart: 'select * from x',
intermediateContent: '',
tables: [
{
tableAlias: 'x',
arguments: ['3.Resources/data/file.csv'],
type: 'file',
sourceFile: '2025-01-01.md'
}
]
})
})
})

View file

@ -0,0 +1,10 @@
import { getFileExtension } from "./extractExtension"
describe('extractExtension', () => {
it('should properly parse file', () => {
expect(getFileExtension('a.csv')).toEqual('csv')
expect(getFileExtension('A.CSV')).toEqual('csv')
expect(getFileExtension('a/b/c/d/e/f.csv')).toEqual('csv')
expect(getFileExtension('3.Resources/a/b/c.csv')).toEqual('csv')
})
})

View file

@ -0,0 +1,4 @@
export function getFileExtension(pathname: string): string | null {
const parts = pathname.split('.')
return parts[parts.length - 1].toLowerCase()
}

View file

@ -29,5 +29,6 @@
"0.18.0": "0.15.0",
"0.18.1": "0.15.0",
"0.19.0": "0.15.0",
"0.19.1": "0.15.0"
"0.19.1": "0.15.0",
"0.19.2": "0.15.0"
}