johman10 / flood-for-transmission

A Flood (https://github.com/Flood-UI/flood) clone for Transmission
GNU General Public License v3.0
339 stars 33 forks source link

Destination folder validation issue on Windows #516

Closed AndrewGail closed 1 year ago

AndrewGail commented 1 year ago

Hi @johman10,

Loving the Flood port, but I ran into an issue with the Flood UI when trying to manually add a torrent, I get a "Destination must be an absolute path" validation error on the Destination field. Looking at the source it seems the regex validation is specific to linux paths: pattern="^/.*$"

https://github.com/johman10/flood-for-transmission/blob/5a59f673812f598ed3ab89b49ef309cc382dc3ab/src/components/Modal/Add/Add.svelte#L150

I think a more expansive regex pattern along the lines of pattern="^(\/.*|[a-zA-Z]:\\(?:([^<>:\"\/\\|?*]*[^<>:\"\/\\|?*.]\\|..\\)*([^<>:\"\/\\|?*]*[^<>:\"\/\\|?*.]\\?|..\\))?)$" should work. I've tested locally on my instance and seems fine.

https://regex101.com/r/tgle0L/1

I think Transmission also supports UNC paths for the destination but I've never used them so can't confirm and haven't allowed for it in the regex.

johman10 commented 1 year ago

Thanks for the report @AndrewGail.

My suggestion is to simplify the Regex a little and just check with: ^(/|[a-zA-Z]:\\).*$

I will open a quick PR for this now.