Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #364 - redirect root at root path spa #369

Merged
merged 1 commit into from
Apr 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ const customRouter = function (req) {

log.debug({ router: { step: "matching", incUrl: url } }, "matching incoming path against spaship directory list");

// See if this URL is hosted by SPAship
// See if this URL is hosted by SPAship at a specific non-root sub-path e.g. /foo
for (let flatDir of topLevelDirsCache) {
spaPath = flatpath.toUrl(flatDir);
if (spaPath === "/") continue; // Ignore root path spa here we will check that later

let regEx = new RegExp("^" + spaPath + "([/\\?].*)?$");
regExMatch = url.match(regEx);
if (regExMatch) {
Expand All @@ -61,7 +63,7 @@ const customRouter = function (req) {
}

if (!matchFound) {
// Check if ROOTSPA exists
// See if SPAship hosts a spa at the root path "/", check if ROOTSPA exists
if (topLevelDirsCache.indexOf("ROOTSPA") >= 0) {
matchedFlatDir = "/ROOTSPA";
spaPath = "/";
Expand Down
12 changes: 6 additions & 6 deletions packages/router/package-lock.json

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