tauri-docs icon indicating copy to clipboard operation
tauri-docs copied to clipboard

wired result of `basename(file, extname(file))`

Open wsw0108 opened this issue 1 year ago • 3 comments

use ext from call extname for basename return wired result:

const ext = await extname('some-json-file.json'); // 'json'
const nameNoExt = await basename('some-json-file.json', ext); // 'some--file.'

Maybe the correct usage is as below?:

const ext = await extname('some-json-file.json'); // 'json'
const nameNoExt = await basename('some-json-file.json', '.' + ext); // some-json-file

wsw0108 avatar Mar 03 '24 09:03 wsw0108

Thanks for the report. I think this includes 2 action items.

  1. Update the docs to be clear about the . requirement.
  2. Change the implementation from the currently used replace to maybe something like rsplit_once to make sure we a) don't replace multiple occurences and b) make sure we replace the right most occurence.

FabianLars avatar Mar 04 '24 13:03 FabianLars

/upstream tauri-apps/tauri

FabianLars avatar Mar 04 '24 13:03 FabianLars

/upstream tauri-apps/plugins-workspace

FabianLars avatar Mar 04 '24 13:03 FabianLars

the correct usage would be to add the dot e.g. basename("path/to/file.json", ".json") however the implementation has a bug as fabian mentioned and we should instead use .strip_suffix(), I will open PRs to fix this behavior

amrbashir avatar Mar 12 '24 15:03 amrbashir

Upstream issue at https://github.com/tauri-apps/plugins-workspace/issues/1020 has been closed.

tauri-apps[bot] avatar Mar 12 '24 16:03 tauri-apps[bot]

PRs for v1 https://github.com/tauri-apps/tauri/pull/9166 and v2 https://github.com/tauri-apps/tauri/pull/9165

amrbashir avatar Mar 12 '24 16:03 amrbashir

Upstream issue at https://github.com/tauri-apps/tauri/issues/9064 has been closed.

tauri-apps[bot] avatar Mar 18 '24 11:03 tauri-apps[bot]