fixed getRelativePath in lib/path.awk

This commit is contained in:
Abdullah Islam 2023-06-21 17:42:26 +06:00
parent cb71f73b96
commit 56baeefaf6
3 changed files with 11 additions and 8 deletions

View File

@ -30,8 +30,8 @@ function resolvePath(path, resolvedPath, pathComponents) {
}
function getRelativePath(base, path, resolvedPath, baseComponents, pathComponents, commonPrefix) {
path = resolvePath(ENVIRON["PWD"] "/" path)
base = resolvePath(ENVIRON["PWD"] "/" base)
path = resolvePath(path)
base = resolvePath(base)
pathComponents[1] = ""
baseComponents[1] = ""
isCommonPrefixUnfinished = 1
@ -39,6 +39,9 @@ function getRelativePath(base, path, resolvedPath, baseComponents, pathComponent
sub(/\/+$/, "", base)
sub(/\/+$/, "", path)
split(path, pathComponents, "/")
split(base, baseComponents, "/")
for (i in pathComponents)
if (baseComponents[i] == pathComponents[i] && isCommonPrefixUnfinished)
resolvedPath = resolvedPath "../"

View File

@ -1,7 +1,7 @@
Navigation:
=> gmi/index.gmi home
=> gmi/sitemap.gmi sitemap
=> gmi/feed.atom feed
=> gmi/index.gmi/ home
=> gmi/sitemap.gmi/ sitemap
=> gmi/feed.atom/ feed
=> http://git.vern.cc/techn0path/ git
# Testing Input

View File

@ -17,9 +17,9 @@ hr { max-width: 70ch; }
<body>
<header>
<nav id='navbar'>
<a href='../html/index.html'>home</a> |
<a href='../html/sitemap.html'>sitemap</a> |
<a href='../html/feed.atom'>feed</a> |
<a href='html/index.html/'>home</a> |
<a href='html/sitemap.html/'>sitemap</a> |
<a href='html/feed.atom/'>feed</a> |
<a href='http://git.vern.cc/techn0path/'>git</a>
</nav><br>