GRAILS-8809 fix for relative image URLs on windows

baseDir.absolutePath (line 50) returns on a windows system a path with backslashes. These will be removed by the replaceAll statement in line 60. A better way to create a file-URL from the basepath is to use baseDir.toPath().toUri().toString() which will return on *nix and windows systems a valid file-URL.
baseDir.toPath().toUri().toString() returns a trailing slash if baseDir is a directory, no slash otherwise. To ensure that we always have a trailing slash, I've added the line
base += base.endsWith('/')?'':'/'