summaryrefslogtreecommitdiff
path: root/web/src/pkg.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'web/src/pkg.tsx')
-rw-r--r--web/src/pkg.tsx19
1 files changed, 9 insertions, 10 deletions
diff --git a/web/src/pkg.tsx b/web/src/pkg.tsx
index 60a51bb..6705982 100644
--- a/web/src/pkg.tsx
+++ b/web/src/pkg.tsx
@@ -13,18 +13,17 @@ function downloadFile( file: string ) {
function urlForHref( href: string, isdir: boolean ) {
const url = new URL( window.location.href );
+ let path = url.pathname;
if( isdir ) {
- const path = url.pathname;
if( path.endsWith( '/' ) ) {
return path + href;
}
return path + "/" + href;
}
- let searchParams = url.searchParams.toString();
- searchParams = searchParams.slice( searchParams.indexOf( '/' ) );
- searchParams = searchParams.slice( searchParams.indexOf( '/' ) );
- return "https://networkheaven.net/pkgs" + searchParams + "/" + href;
+ path = path.slice( path.indexOf( '/pkgs' ) + 5 );
+ if( path.endsWith( '/' ) )
+ return "https://networkheaven.net/pkgs" + path + "" + href;
}
interface PkgEntry {
@@ -80,7 +79,6 @@ async function getEntries(): Promise<PkgEntry[]> {
const pre = pkgBody.find( "pre" )[0].innerText;
const ret = [];
- console.log( url.pathname );
if( !url.pathname.endsWith( "/pkg/" ) && !url.pathname.endsWith( "/pkg" ) ) {
ret.push({
name: '../',
@@ -97,7 +95,6 @@ async function getEntries(): Promise<PkgEntry[]> {
continue;
const entry = entryFromLine( line );
- console.log( entry );
if( entry )
ret.push( entry );
}
@@ -114,16 +111,18 @@ function back() {
}
function PackageEntry( props: any ) {
- console.log( props );
const entry = props.entry as PkgEntry;
- console.log( urlForHref( entry.name, entry.isdir ) );
return <tr>
<td>
{ entry.name == "../" &&
<a href='#' onclick={ () => back() } class="package-entry-link">
../
</a> }
- { entry.name != "../" &&
+ { entry.name != "../" && !entry.isdir &&
+ <a href={urlForHref( entry.name, entry.isdir )} class="package-entry-link">
+ {entry.name}
+ </a> }
+ { entry.name != "../" && entry.isdir &&
<a href='#' onclick={ () => JSX.navigate( urlForHref( entry.name, entry.isdir ) ) } class="package-entry-link">
{entry.name}
</a> }