roots-netlify
Advanced tools
Comparing version 0.0.4 to 0.1.0
@@ -1,4 +0,4 @@ | ||
// Generated by CoffeeScript 1.7.1 | ||
// Generated by CoffeeScript 1.10.0 | ||
(function() { | ||
var RootsUtil, W, path, _; | ||
var RootsUtil, W, _, path; | ||
@@ -14,4 +14,3 @@ RootsUtil = require('roots-util'); | ||
module.exports = function(opts) { | ||
var RootsNetlify, codes; | ||
codes = ['200', '301', '302', '404']; | ||
var RootsNetlify; | ||
return RootsNetlify = (function() { | ||
@@ -29,3 +28,2 @@ var write_headers, write_redirects; | ||
redirects: {}, | ||
rewrites: {}, | ||
headers: {} | ||
@@ -42,3 +40,3 @@ }); | ||
var k, v; | ||
str += "" + path + "\n"; | ||
str += path + "\n"; | ||
for (k in conf) { | ||
@@ -54,20 +52,4 @@ v = conf[k]; | ||
write_redirects = function() { | ||
var redirects, res; | ||
redirects = _.pick(this.opts.redirects, codes); | ||
if (redirects['200'] == null) { | ||
redirects['200'] = {}; | ||
} | ||
if (redirects['301'] == null) { | ||
redirects['301'] = {}; | ||
} | ||
_.merge(redirects['200'], this.opts.rewrites); | ||
_.merge(redirects['301'], _.omit(this.opts.redirects, codes)); | ||
res = _.reduce(redirects, function(str, conf, code) { | ||
var k, v; | ||
for (k in conf) { | ||
v = conf[k]; | ||
str += "" + k + " " + v + " " + code + "\n"; | ||
} | ||
return str; | ||
}, ''); | ||
var res; | ||
res = this.opts.redirects.join('\n'); | ||
return this.util.write('_redirects', res); | ||
@@ -74,0 +56,0 @@ }; |
{ | ||
"name": "roots-netlify", | ||
"version": "0.0.4", | ||
"version": "0.1.0", | ||
"description": "A roots extension for configuring netlify", | ||
@@ -5,0 +5,0 @@ "main": "lib", |
@@ -30,12 +30,10 @@ Roots Netlify | ||
netlify | ||
redirects: | ||
'/news': '/blog' | ||
'/news/:year/:month:/:date/:slug': '/blog/:year/:month/:date/:story_id' | ||
'/news/*': '/blog/:splat' | ||
'302': | ||
'/temp_redirect': '/' | ||
'404': | ||
'/ecommerce': '/closed' | ||
rewrites: | ||
'/*': '/index.html' | ||
redirects: [ | ||
'/news /blog 200' | ||
'/news/:year/:month:/:date/:slug /blog/:year/:month/:date/:story_id 200' | ||
'/news/* /blog/:splat 200' | ||
'/redirect / 301' | ||
'/temp_redirect / 302' | ||
'/ecommerce /closed 404' | ||
] | ||
headers: | ||
@@ -53,3 +51,3 @@ '/protected/path': | ||
Redirects added to the `redirects` object return a status code of `301` while those added to the `rewrites` object will return `200` (a rewrite). Netlify also [supports](https://docs.netlify.com/redirects#http-status-codes) two other status codes: `302` and `404`. In order to configure your redirects for these, add a `302` or `404` key to `redirects` and nest your configuration object there (see example above). | ||
The `redirects` property accepts an array of redirects or rewrite rules (in order) with their respective HTTP code appended at the end as described in Netlify's documentation. | ||
@@ -56,0 +54,0 @@ ### Promises |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
14474
47
75
1