#convert absolute to relative path

13 messages · Page 1 of 1 (latest)

north salmon
#

how can i convert an absolute path to relative?
i would like to use like the path package, but i cant get it to work

dapper portal
#

What have you tried and what issue(s) are you experiencing?

odd kernel
north salmon
#
Uncaught ReferenceError: process is not defined
    at node_modules/path/path.js (path.js:25:17)
    at __require (chunk-65LFK76I.js?v=af3ca2f0:5:50)
    at path.js:628:24
import * as path from "path".
#

i just want to relative an absolute path.
eg: relative('C:/beans/taco', 'C:/') = ./beans/taco/

lapis arrow
#

Node.js core libraries don't work in Tauri when you build for production as there is no Node.js runtime.

#

I took a look at the Node.js source code for relative and it's fairly straight-forward to replicate for yourself.

north salmon
#

ik, but i wanted a "normal" way of doing it, like why doesn't tauri/api/path not have it?

lapis arrow
#

You're the first person to ask for it.

#

What is your use-case for it?

north salmon
#

representing a path to the user. when they click it it would bring them to the file in explorer.

#

there isn't a reason to show the user a full path.

lapis arrow
#

What would the path be relative to? The working directory of the app?