fixed getRelativePath in lib/path.awk
This commit is contained in:
parent
cb71f73b96
commit
56baeefaf6
|
@ -30,8 +30,8 @@ function resolvePath(path, resolvedPath, pathComponents) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRelativePath(base, path, resolvedPath, baseComponents, pathComponents, commonPrefix) {
|
function getRelativePath(base, path, resolvedPath, baseComponents, pathComponents, commonPrefix) {
|
||||||
path = resolvePath(ENVIRON["PWD"] "/" path)
|
path = resolvePath(path)
|
||||||
base = resolvePath(ENVIRON["PWD"] "/" base)
|
base = resolvePath(base)
|
||||||
pathComponents[1] = ""
|
pathComponents[1] = ""
|
||||||
baseComponents[1] = ""
|
baseComponents[1] = ""
|
||||||
isCommonPrefixUnfinished = 1
|
isCommonPrefixUnfinished = 1
|
||||||
|
@ -39,6 +39,9 @@ function getRelativePath(base, path, resolvedPath, baseComponents, pathComponent
|
||||||
sub(/\/+$/, "", base)
|
sub(/\/+$/, "", base)
|
||||||
sub(/\/+$/, "", path)
|
sub(/\/+$/, "", path)
|
||||||
|
|
||||||
|
split(path, pathComponents, "/")
|
||||||
|
split(base, baseComponents, "/")
|
||||||
|
|
||||||
for (i in pathComponents)
|
for (i in pathComponents)
|
||||||
if (baseComponents[i] == pathComponents[i] && isCommonPrefixUnfinished)
|
if (baseComponents[i] == pathComponents[i] && isCommonPrefixUnfinished)
|
||||||
resolvedPath = resolvedPath "../"
|
resolvedPath = resolvedPath "../"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
Navigation:
|
Navigation:
|
||||||
=> gmi/index.gmi home
|
=> gmi/index.gmi/ home
|
||||||
=> gmi/sitemap.gmi sitemap
|
=> gmi/sitemap.gmi/ sitemap
|
||||||
=> gmi/feed.atom feed
|
=> gmi/feed.atom/ feed
|
||||||
=> http://git.vern.cc/techn0path/ git
|
=> http://git.vern.cc/techn0path/ git
|
||||||
|
|
||||||
# Testing Input
|
# Testing Input
|
||||||
|
|
|
@ -17,9 +17,9 @@ hr { max-width: 70ch; }
|
||||||
<body>
|
<body>
|
||||||
<header>
|
<header>
|
||||||
<nav id='navbar'>
|
<nav id='navbar'>
|
||||||
<a href='../html/index.html'>home</a> |
|
<a href='html/index.html/'>home</a> |
|
||||||
<a href='../html/sitemap.html'>sitemap</a> |
|
<a href='html/sitemap.html/'>sitemap</a> |
|
||||||
<a href='../html/feed.atom'>feed</a> |
|
<a href='html/feed.atom/'>feed</a> |
|
||||||
<a href='http://git.vern.cc/techn0path/'>git</a>
|
<a href='http://git.vern.cc/techn0path/'>git</a>
|
||||||
</nav><br>
|
</nav><br>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue