forked from adonisjs/adonis-fullstack-app
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Pulipuli Chen
committed
Oct 7, 2019
1 parent
34aa53f
commit 8cfdfa1
Showing
3 changed files
with
25 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,25 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
'use strict' | ||
|
||
const Config = use('Config') | ||
let directoryIndexMapping = Config.get('referer.directoryIndexMapping') | ||
|
||
let RefererPathFilter = function (referer) { | ||
|
||
if (typeof(referer) !== 'string') { | ||
return '/' | ||
} | ||
|
||
let refererPath = '/' + referer.split('/').slice(3).join('/') | ||
|
||
for (let i = 0; i < directoryIndexMapping.length; i++) { | ||
let needle = directoryIndexMapping[i] | ||
if (refererPath.startsWith(needle) === true) { | ||
refererPath = '/' + refererPath.slice(needle.length) | ||
break | ||
} | ||
} | ||
|
||
return refererPath | ||
} | ||
|
||
module.exports = RefererPathFilter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters