mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-12 11:15:14 +00:00
prevent client-side navigation to server routes - fixes #145
This commit is contained in:
@@ -22,8 +22,11 @@ function generate_client(routes: Route[], src: string, dev: boolean, dev_port?:
|
||||
// This file is generated by Sapper — do not edit it!
|
||||
export const routes = [
|
||||
${routes
|
||||
.filter(route => route.type === 'page')
|
||||
.map(route => {
|
||||
if (route.type !== 'page') {
|
||||
return `{ pattern: ${route.pattern}, ignore: true }`;
|
||||
}
|
||||
|
||||
const file = posixify(`../../routes/${route.file}`);
|
||||
|
||||
if (route.id === '_4xx' || route.id === '_5xx') {
|
||||
|
||||
@@ -26,6 +26,8 @@ function select_route(url: URL): Target {
|
||||
for (const route of routes) {
|
||||
const match = route.pattern.exec(url.pathname);
|
||||
if (match) {
|
||||
if (route.ignore) return null;
|
||||
|
||||
const params = route.params(match);
|
||||
|
||||
const query: Record<string, string | true> = {};
|
||||
|
||||
@@ -14,7 +14,8 @@ export interface Component {
|
||||
export type Route = {
|
||||
pattern: RegExp;
|
||||
params: (match: RegExpExecArray) => Record<string, string>;
|
||||
load: () => Promise<{ default: ComponentConstructor }>
|
||||
load: () => Promise<{ default: ComponentConstructor }>;
|
||||
ignore?: boolean;
|
||||
};
|
||||
|
||||
export type ScrollPosition = {
|
||||
|
||||
Reference in New Issue
Block a user