chore(tools): Fix doc inclusion tools on Windows (#13685)

This commit is contained in:
Chase Sterling 2023-07-28 09:44:04 -04:00 committed by GitHub
parent 043aa0374b
commit 1f3b7e86ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 5 deletions

View File

@ -91,7 +91,7 @@ func main() {
newUnresolved := make(map[string]string)
for name, fn := range unresolved {
if filepath.IsAbs(fn) {
if strings.HasPrefix(filepath.ToSlash(fn), "/") {
fn = filepath.Join(root, fn)
}
@ -121,7 +121,7 @@ func main() {
pwd = string(filepath.Separator) + pwd
for _, iname := range extractIncludes(tmpl) {
ifn := iname
if !filepath.IsAbs(ifn) {
if !strings.HasPrefix(ifn, "/") {
ifn = filepath.Join(pwd, ifn)
}
newUnresolved[iname] = ifn

View File

@ -52,10 +52,9 @@ func extractIncludeBlock(txt []byte, includesEx *regexp.Regexp, root string) *in
if len(inc) != 2 {
continue
}
include := filepath.FromSlash(string(inc[1]))
include := string(inc[1])
// Make absolute paths relative to the include-root if any
// Check original value to avoid platform specific slashes
if filepath.IsAbs(string(inc[1])) {
if strings.HasPrefix(include, "/") {
if root == "" {
log.Printf("Ignoring absolute include %q without include root...", include)
continue