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

feat(redirects): handle absolute from paths when path prefix is used #12509

Merged
merged 3 commits into from
Mar 13, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
313 changes: 313 additions & 0 deletions packages/gatsby/src/redux/__tests__/__snapshots__/redirects.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,313 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Add redirects allows you to add redirects 1`] = `
Object {
"payload": Object {
"fromPath": "/old/hello-world",
"isPermanent": false,
"redirectInBrowser": false,
"toPath": "/new/hello-world",
},
"type": "CREATE_REDIRECT",
}
`;

exports[`Add redirects create redirects as permanent 1`] = `
Object {
"payload": Object {
"fromPath": "/old/hello-world",
"isPermanent": true,
"redirectInBrowser": false,
"toPath": "/new/hello-world",
},
"type": "CREATE_REDIRECT",
}
`;

exports[`Add redirects creates redirects from the URL starts with // 1`] = `
Object {
"payload": Object {
"fromPath": "//example.com",
"isPermanent": false,
"redirectInBrowser": false,
"toPath": "/new/hello-world-2",
},
"type": "CREATE_REDIRECT",
}
`;

exports[`Add redirects creates redirects from the URL starts with ftp 1`] = `
Object {
"payload": Object {
"fromPath": "ftp://example.com",
"isPermanent": false,
"redirectInBrowser": false,
"toPath": "/new/hello-world-3",
},
"type": "CREATE_REDIRECT",
}
`;

exports[`Add redirects creates redirects from the URL starts with http 1`] = `
Object {
"payload": Object {
"fromPath": "http://example.com",
"isPermanent": false,
"redirectInBrowser": false,
"toPath": "/new/hello-world-1",
},
"type": "CREATE_REDIRECT",
}
`;

exports[`Add redirects creates redirects from the URL starts with https 1`] = `
Object {
"payload": Object {
"fromPath": "https://example.com",
"isPermanent": false,
"redirectInBrowser": false,
"toPath": "/new/hello-world-0",
},
"type": "CREATE_REDIRECT",
}
`;

exports[`Add redirects creates redirects from the URL starts with mailto 1`] = `
Object {
"payload": Object {
"fromPath": "mailto:example@email.com",
"isPermanent": false,
"redirectInBrowser": false,
"toPath": "/new/hello-world-4",
},
"type": "CREATE_REDIRECT",
}
`;

exports[`Add redirects creates redirects to the URL starts with // 1`] = `
Object {
"payload": Object {
"fromPath": "/old/hello-world-2",
"isPermanent": false,
"redirectInBrowser": false,
"toPath": "//example.com",
},
"type": "CREATE_REDIRECT",
}
`;

exports[`Add redirects creates redirects to the URL starts with ftp 1`] = `
Object {
"payload": Object {
"fromPath": "/old/hello-world-3",
"isPermanent": false,
"redirectInBrowser": false,
"toPath": "ftp://example.com",
},
"type": "CREATE_REDIRECT",
}
`;

exports[`Add redirects creates redirects to the URL starts with http 1`] = `
Object {
"payload": Object {
"fromPath": "/old/hello-world-1",
"isPermanent": false,
"redirectInBrowser": false,
"toPath": "http://example.com",
},
"type": "CREATE_REDIRECT",
}
`;

exports[`Add redirects creates redirects to the URL starts with https 1`] = `
Object {
"payload": Object {
"fromPath": "/old/hello-world-0",
"isPermanent": false,
"redirectInBrowser": false,
"toPath": "https://example.com",
},
"type": "CREATE_REDIRECT",
}
`;

exports[`Add redirects creates redirects to the URL starts with mailto 1`] = `
Object {
"payload": Object {
"fromPath": "/old/hello-world-4",
"isPermanent": false,
"redirectInBrowser": false,
"toPath": "mailto:example@email.com",
},
"type": "CREATE_REDIRECT",
}
`;

exports[`Add redirects creates redirects with in-browser redirect option 1`] = `
Object {
"payload": Object {
"fromPath": "/old/hello-world",
"isPermanent": false,
"redirectInBrowser": true,
"toPath": "/new/hello-world",
},
"type": "CREATE_REDIRECT",
}
`;

exports[`Add redirects with path prefixs allows you to add redirects 1`] = `
Object {
"payload": Object {
"fromPath": "/blog/old/hello-world",
"isPermanent": false,
"redirectInBrowser": false,
"toPath": "/blog/new/hello-world",
},
"type": "CREATE_REDIRECT",
}
`;

exports[`Add redirects with path prefixs create redirects as permanent 1`] = `
Object {
"payload": Object {
"fromPath": "/blog/old/hello-world",
"isPermanent": true,
"redirectInBrowser": false,
"toPath": "/blog/new/hello-world",
},
"type": "CREATE_REDIRECT",
}
`;

exports[`Add redirects with path prefixs creates redirects from the URL starts with // 1`] = `
Object {
"payload": Object {
"fromPath": "//example.com",
"isPermanent": false,
"redirectInBrowser": false,
"toPath": "/blog/new/hello-world-2",
},
"type": "CREATE_REDIRECT",
}
`;

exports[`Add redirects with path prefixs creates redirects from the URL starts with ftp 1`] = `
Object {
"payload": Object {
"fromPath": "ftp://example.com",
"isPermanent": false,
"redirectInBrowser": false,
"toPath": "/blog/new/hello-world-3",
},
"type": "CREATE_REDIRECT",
}
`;

exports[`Add redirects with path prefixs creates redirects from the URL starts with http 1`] = `
Object {
"payload": Object {
"fromPath": "http://example.com",
"isPermanent": false,
"redirectInBrowser": false,
"toPath": "/blog/new/hello-world-1",
},
"type": "CREATE_REDIRECT",
}
`;

exports[`Add redirects with path prefixs creates redirects from the URL starts with https 1`] = `
Object {
"payload": Object {
"fromPath": "https://example.com",
"isPermanent": false,
"redirectInBrowser": false,
"toPath": "/blog/new/hello-world-0",
},
"type": "CREATE_REDIRECT",
}
`;

exports[`Add redirects with path prefixs creates redirects from the URL starts with mailto 1`] = `
Object {
"payload": Object {
"fromPath": "mailto:example@email.com",
"isPermanent": false,
"redirectInBrowser": false,
"toPath": "/blog/new/hello-world-4",
},
"type": "CREATE_REDIRECT",
}
`;

exports[`Add redirects with path prefixs creates redirects to the URL starts with // 1`] = `
Object {
"payload": Object {
"fromPath": "/blog/old/hello-world-2",
"isPermanent": false,
"redirectInBrowser": false,
"toPath": "//example.com",
},
"type": "CREATE_REDIRECT",
}
`;

exports[`Add redirects with path prefixs creates redirects to the URL starts with ftp 1`] = `
Object {
"payload": Object {
"fromPath": "/blog/old/hello-world-3",
"isPermanent": false,
"redirectInBrowser": false,
"toPath": "ftp://example.com",
},
"type": "CREATE_REDIRECT",
}
`;

exports[`Add redirects with path prefixs creates redirects to the URL starts with http 1`] = `
Object {
"payload": Object {
"fromPath": "/blog/old/hello-world-1",
"isPermanent": false,
"redirectInBrowser": false,
"toPath": "http://example.com",
},
"type": "CREATE_REDIRECT",
}
`;

exports[`Add redirects with path prefixs creates redirects to the URL starts with https 1`] = `
Object {
"payload": Object {
"fromPath": "/blog/old/hello-world-0",
"isPermanent": false,
"redirectInBrowser": false,
"toPath": "https://example.com",
},
"type": "CREATE_REDIRECT",
}
`;

exports[`Add redirects with path prefixs creates redirects to the URL starts with mailto 1`] = `
Object {
"payload": Object {
"fromPath": "/blog/old/hello-world-4",
"isPermanent": false,
"redirectInBrowser": false,
"toPath": "mailto:example@email.com",
},
"type": "CREATE_REDIRECT",
}
`;

exports[`Add redirects with path prefixs creates redirects with in-browser redirect option 1`] = `
Object {
"payload": Object {
"fromPath": "/blog/old/hello-world",
"isPermanent": false,
"redirectInBrowser": true,
"toPath": "/blog/new/hello-world",
},
"type": "CREATE_REDIRECT",
}
`;
Loading