Repository: single-spa/single-spa-layout (js)

Issue:
LayoutEngine: route matching with only trailing "/"
**Describe the bug or question**
When defining base path of  "/something" and route path of "/", the route will only match to "/something/" and not "/something". Since route does not allow empty strings as a route.

**Expected behavior**
route "/something" will match

**Screenshots and/or console output**
If applicable, add screenshots or console output to help explain your problem.

**Additional context**
Why is empty route string not allowed when according to documentation leading and trailing slashes are not needed?


Pull request description:
Fix bug with trailing slashes. Resolves #64.
See #64 

Patch:
diff --git a/src/isomorphic/matchRoute.js b/src/isomorphic/matchRoute.js
index be0602a..66ade44 100644
--- a/src/isomorphic/matchRoute.js
+++ b/src/isomorphic/matchRoute.js
@@ -60,17 +60,23 @@ function recurseRoutes(location, routes) {
 }
 
 export function resolvePath(prefix, path) {
+  let result;
+
   if (prefix.substr(-1) === "/") {
     if (path[0] === "/") {
-      return prefix + path.slice(1);
+      result = prefix + path.slice(1);
     } else {
-      return prefix + path;
+      result = prefix + path;
     }
+  } else if (path[0] === "/") {
+    result = prefix + path;
   } else {
-    if (path[0] === "/") {
-      return prefix + path;
-    } else {
-      return prefix + "/" + path;
-    }
+    result = prefix + "/" + path;
   }
+
+  if (result.substr(-1) === "/") {
+    result = result.slice(0, result.length - 1);
+  }
+
+  return result;
 }


Test patch:
diff --git a/test/constructApplications.test.js b/test/constructApplications.test.js
index eba8f54..f3b173a 100644
--- a/test/constructApplications.test.js
+++ b/test/constructApplications.test.js
@@ -333,6 +333,35 @@ describe(`constructApplications`, () => {
       `);
     }
   });
+
+  // https://github.com/single-spa/single-spa-layout/issues/64
+  it(`does not require trailing slashes after base path`, () => {
+    const routes = constructRoutes({
+      mode: "history",
+      base: "/something",
+      routes: [
+        {
+          type: "route",
+          path: "/",
+          routes: [
+            {
+              type: "application",
+              name: "app1",
+            },
+          ],
+        },
+      ],
+    });
+
+    async function loadApp() {}
+
+    const applications = constructApplications({ routes, loadApp });
+    expect(applications.length).toBe(1);
+    const app1 = applications[0];
+    expect(
+      app1.activeWhen.some((fn) => fn(new URL("http://example.com/something")))
+    ).toBe(true);
+  });
 });
 
 function tick() {