Skip to content

Commit

Permalink
add overwrite.ignoreIfTrue
Browse files Browse the repository at this point in the history
  • Loading branch information
Luna-devv committed Apr 10, 2023
1 parent d320da8 commit 1f6b1a5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ export type Host = {
type: "WEB" | "REDIRECT"
target: number | string
ip?: string
ignoreIfTrue?: (req) => boolean;
}[]
};
10 changes: 6 additions & 4 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@ export async function requestManager(req, res) {
};

// managing overwrites
if (overwrites) {
if (overwrites && req.url !== '/') {
for (const overwrite of overwrites) {

if (
(typeof overwrite.path === 'string' ? (req.url.includes('?') ? req.url.split('?')[0] : req.url) == overwrite.path : overwrite.path.includes(req.url.includes('?') ? req.url.split('?')[0] : req.url))
|| (typeof overwrite.path === 'string' && overwrite.path.endsWith('/*') && (req.url.includes('?') ? req.url.split('?')[0] : req.url).startsWith(overwrite.path.slice(0, -1)))
|| overwrite.path === '/*'
!(overwrite.ignoreIfTrue?.(req) || false) && (
(typeof overwrite.path === 'string' ? (req.url.includes('?') ? req.url.split('?')[0] : req.url) == overwrite.path : overwrite.path.includes(req.url.includes('?') ? req.url.split('?')[0] : req.url))
|| (typeof overwrite.path === 'string' && overwrite.path.endsWith('/*') && (req.url.includes('?') ? req.url.split('?')[0] : req.url).startsWith(overwrite.path.slice(0, -1)))
|| overwrite.path === '/*'
)
) {

// Proxy overwrite
Expand Down

0 comments on commit 1f6b1a5

Please sign in to comment.