koa-classic-server 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +11 -6
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -48,7 +48,15 @@ module.exports = function koaClassicServer(
48
48
  return;
49
49
  }
50
50
 
51
- const pageHref = new URL(ctx.href);
51
+ //faccio in modo che la formula finale sia senza il "/" finale es 'http://localhost:3000/manage' e non 'http://localhost:3000/manage/' questo per non generare risultati diversi
52
+ // attenione questo vale anche per la rotto che passa da http://localhost:3000/ a http://localhost:3000 però questa cosa verràcorretta portando il caso base con il '/' in più da : new URL(ctx.href)
53
+ let pageHref = ''; //conterrà l'href della pagina
54
+ if(ctx.href.charAt(ctx.href.length - 1) == '/'){
55
+ pageHref = new URL(ctx.href.slice(0, -1));// slice(0, -1); rimuovo l'ultimo carattere '/'
56
+ }else{
57
+ pageHref = new URL(ctx.href);
58
+ }
59
+
52
60
  //console.log( "rootDir="+rootDir+" UrlPrefix="+options.urlPrefix+" pageHref.pathname="+pageHref.pathname );
53
61
 
54
62
  // adesso controllo se pageHref rientraun urlPrefix
@@ -180,7 +188,7 @@ module.exports = function koaClassicServer(
180
188
 
181
189
  // START PARENT directory
182
190
  if (pageHrefOutPrefix.origin + "/" != pageHrefOutPrefix.href) {
183
- // allora non sei nella cartella base e bisogn visualizzare il linkalla Parent Directory
191
+ // allora non sei nella cartella base e bisogn visualizzare il link alla Parent Directory
184
192
  const a_pD = pageHref.href.split("/"); // array che conterrà il link della parent directori e che poi verrà ricostruito in stringa
185
193
  a_pD.pop(); // rimuovo l'ultimo elemento per trasormarla dell parent directory
186
194
  const parentDirectory = a_pD.join("/");
@@ -217,10 +225,7 @@ module.exports = function koaClassicServer(
217
225
 
218
226
  const itemPath = `${toOpen}/${s_name}`;
219
227
  let itemUri = "";
220
- if (
221
- pageHref.href ==
222
- pageHref.origin + options.urlPrefix + "/"
223
- ) {
228
+ if ( pageHref.href == pageHref.origin + options.urlPrefix + "/" ) {
224
229
  // senza questo if else vi rarà sempre un "/" in più o in meno alla fine dell'origin
225
230
  itemUri = `${
226
231
  pageHref.origin + options.urlPrefix
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koa-classic-server",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "a server in style Apache 2",
5
5
  "main": "index.js",
6
6
  "scripts": {