This repository was archived by the owner on Oct 20, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Original file line number Diff line number Diff line change 1+ const path = require ( 'path' )
2+
3+ const test = require ( 'ava' )
4+ const parser = require ( './netlify-config-parser' )
5+
6+ const testFilesDir = path . resolve ( '__dirname' , '../' , 'test-files' )
7+
8+ test ( 'netlify.toml redirects parsing' , async t => {
9+ const result = await parser . parse ( path . resolve ( testFilesDir , 'netlify.toml' ) )
10+ t . deepEqual (
11+ [
12+ {
13+ path : '/old-path' ,
14+ to : '/new-path' ,
15+ status : 301 ,
16+ conditions : {
17+ Country : [ 'US' ] ,
18+ Language : [ 'en' ] ,
19+ Role : [ 'admin' ] ,
20+ } ,
21+ force : false ,
22+ params : {
23+ path : ':path' ,
24+ } ,
25+ } ,
26+ {
27+ path : '/search' ,
28+ to : 'https://api.mysearch.com' ,
29+ status : 200 ,
30+ force : true ,
31+ signed : 'API_SIGNATURE_TOKEN' ,
32+ proxy : true ,
33+ headers : {
34+ 'X-From' : 'Netlify' ,
35+ } ,
36+ } ,
37+ ] ,
38+ result . success
39+ )
40+ } )
Original file line number Diff line number Diff line change 1+ [[redirects ]]
2+ from = " /old-path"
3+ to = " /new-path"
4+ status = 301
5+ force = false
6+ query = {path = " :path" }
7+ conditions = {Language = [" en" ], Country = [" US" ], Role = [" admin" ]}
8+
9+ # # This rule redirects to an external API, signing requests with a secret
10+ [[redirects ]]
11+ from = " /search"
12+ to = " https://api.mysearch.com"
13+ status = 200
14+ force = true # COMMENT: ensure that we always redirect
15+ headers = {X-From = " Netlify" }
16+ signed = " API_SIGNATURE_TOKEN"
You can’t perform that action at this time.
0 commit comments