Skip to content

Commit

Permalink
✍️ added comments to describe redirect logic #8
Browse files Browse the repository at this point in the history
  • Loading branch information
8eecf0d2 committed Oct 19, 2018
1 parent 82ca949 commit 6d8400f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/ts/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,20 @@ export class Server {
private routeRedirects (redirects: Netlify.Redirect[]): void {
for(const redirect of redirects) {
// XXX: Need to check if this can be made stricter to just match "http" and "https"

/** Routes which have an absolute urls will be proxied */
if(redirect.to.match(/^(?:[a-z]+:)?\/\//i)) {
this.handleProxy(redirect);
continue;
}

/** Routes which have a 301, 302 or 303 status code are considered typical redirects */
if([301, 302, 303].includes(redirect.status)) {
this.handleRedirect(redirect);
continue;
}

/** Routes which do not match other conditions are assumed to be rewrites */
this.handleRewrite(redirect);
}
}
Expand Down

0 comments on commit 6d8400f

Please sign in to comment.