Skip to content

Commit

Permalink
Fixes some issues (#43)
Browse files Browse the repository at this point in the history
- normalise base for when it is not set
  • Loading branch information
mxdvl authored Jul 11, 2023
2 parents e120fb9 + 49e8275 commit 4c168ee
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/esbuild_plugins/svelte_components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
} from "https://deno.land/[email protected]/path/mod.ts";
import type { Plugin } from "https://deno.land/x/[email protected]/mod.js";
import { normalize } from "https://deno.land/[email protected]/path/mod.ts";
import { compile } from "npm:svelte/compiler";
import type { ComponentType } from "npm:svelte";
import { compile } from "npm:svelte@3.58/compiler";
import type { ComponentType } from "npm:svelte@3.58";

const filter = /\.svelte$/;
const name = "mononykus/svelte";
Expand Down
9 changes: 7 additions & 2 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ export const create_handler = (
): Handler => ((req) => {
const url = new URL(req.url);

if (url.pathname.startsWith(normalise("/" + base))) {
return serveDir(req, { fsRoot: out_dir, urlRoot: base });
const normalised_base = normalise("/" + base);

if (url.pathname.startsWith(normalised_base)) {
return serveDir(req, {
fsRoot: out_dir,
urlRoot: normalised_base.slice(1),
});
} else {
return Response.redirect(
new URL(normalise(base + url.pathname), url.origin),
Expand Down

0 comments on commit 4c168ee

Please sign in to comment.