Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

GRAILS-8809 fix for relative image URLs on windows #395

Closed
wants to merge 1 commit into from

2 participants

@rdmueller

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('/')?'':'/'

@rdmueller rdmueller 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('/')?'':'/'
206e0dc
@lhotari
Collaborator

Thanks for the pull request. Please open a new PR that targets the 2.3.x or 2.4.x branch. The master branch is currently for Grails 3.x development so that fixes going in to master won't be released in current stable Grails versions.

@rdmueller

OK. Will try to come up with a proper pull request for the 2.2.x branch, since we are using this one. Hope this will be ok.
Do I also have to create PRs for 2.3.x and 2.4.x or will the PR for 2.2.x automatically show up in higher versions?

@rdmueller rdmueller closed this
@lhotari
Collaborator

@rdmueller We don't have plans to do maintenance releases for the 2.2.x branch any more and we don't merge 2.2.x to other branches.

Currently we merge 2.3.x to 2.4.x and 2.4.x to master so a pull request to 2.3.x branch is sufficient. You can also do a PR for the 2.2.x branch but as I said it's not under active maintenance anymore so the changes to 2.2.x might not get merged and released at all.

It would be interesting to know the reasons for keeping you from upgrading from 2.2.x to 2.4.x . If there are issues, please ask SO questions, report to the mailing list or Grails JIRA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 4, 2013
  1. @rdmueller

    GRAILS-8809 fix for relative image URLs on windows

    rdmueller authored
    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('/')?'':'/'
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 2 deletions.
  1. +4 −2 grails-docs/src/main/groovy/grails/doc/PdfBuilder.groovy
View
6 grails-docs/src/main/groovy/grails/doc/PdfBuilder.groovy
@@ -47,7 +47,9 @@ class PdfBuilder {
File htmlFile = new File(guideDir, "single.html")
File outputFile = new File(guideDir, "single.pdf")
- String xml = createXml(htmlFile, baseDir.absolutePath)
+ String base = baseDir.toPath().toUri().toString()
+ base += base.endsWith('/')?'':'/'
+ String xml = createXml(htmlFile, base)
createPdf xml, outputFile, guideDir
}
@@ -57,7 +59,7 @@ class PdfBuilder {
// fix inner anchors
xml = xml.replaceAll('<a href="\\.\\./guide/single\\.html', '<a href="')
// fix image refs to absolute paths
- xml = xml.replaceAll('src="\\.\\./img/', "src=\"file://${base}/img/")
+ xml = xml.replaceAll('src="\\.\\./img/', "src=\"${base}img/")
// convert tabs to spaces otherwise they only take up one space
xml = xml.replaceAll('\t', ' ')
Something went wrong with that request. Please try again.