mushanshitiancai / vscode-paste-image

paste image from clipboard to markdown/asciidoc directly!
MIT License
426 stars 129 forks source link

encoding image file name #117

Open lghio opened 1 year ago

lghio commented 1 year ago

I'm using this pattern to insert the relative link to my images

${imageFileName}

and unfortunately the spaces aren't encoded.

Could you add an option to encode the variables "imageFileName" ?

Thank you for this great extension

lirantal commented 1 year ago

@lghio there's already logic in the code to handle encoding for spaces. To make that work, you need to enable the config item encodePath and set its value to urlEncodeSpace.

lghio commented 1 year ago

I understand the settings but it only works on the imagePath, it does not work on the imageName and I want to use a relative name, so I can't use the imagePath

lirantal commented 1 year ago

Oh I think you're right, it's encoding applied to the imageFilePath: https://github.com/mushanshitiancai/vscode-paste-image/blob/fb795320aedea24a03e5c7d43d1059e4080277b3/src/extension.ts#L383-L387

It looks like it would be a relatively easy fix to add an encoding for the filename specifically. That's what you're asking for, right?

lghio commented 1 year ago

Yes that's it ;-) When do you think that could be implemented?

lirantal commented 1 year ago

I've no idea, I don't have any access to this repo, just a developer using this extension :-)

lirantal commented 1 year ago

@lghio I submitted a pull request here to suggest the code changes that might fix this issue.

Still, need the maintainer(s) around to review, merge, and publish a new version.