Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional custom rewrites #1

Merged
merged 2 commits into from
Jan 7, 2018
Merged

Optional custom rewrites #1

merged 2 commits into from
Jan 7, 2018

Conversation

lionralfs
Copy link
Contributor

Hey 👋

This adds the possibility to pass an array of custom rewrites to the plugin. A use case for this would be the example from the netlify docs on Proxying:

export default function(config) {
    netlifyPlugin(config, {
        redirects: ['/api/* https://api.example.com/:splat 200']
    });
}

becomes

/api/* https://api.example.com/:splat 200
/* /index.html 200

Copy link
Owner

@vinaypuppal vinaypuppal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, this looks like a useful feature.

  • I've left a comment below apart from that rest looks good to me.
  • Can you add this feature config info to readme as well?

index.js Outdated
@@ -4,6 +4,10 @@
*/

class NetlifyServerPushPlugin {
constructor({ redirects }) {
this.redirects = Array.isArray(redirects) ? redirects : [];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here rather then falling back to [] every time I think we should throw an error if the user does not provide redirects as Array. i.e we should check

  • if a user provided redirects value
    • if its type is Array then assign it to this.redirects
    • else throw an error asking the user to provide it as Array.
  • else assign this.redirects to []

What do you say?

@lionralfs
Copy link
Contributor Author

Thanks for the suggestions @vinaypuppal
I've updated the PR accordingly

Copy link
Owner

@vinaypuppal vinaypuppal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

@vinaypuppal vinaypuppal merged commit eb1d54f into vinaypuppal:master Jan 7, 2018
@lionralfs lionralfs deleted the patch-1 branch January 7, 2018 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants