mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-15 20:34:44 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3531cc587d | ||
|
|
562a91fa57 | ||
|
|
93128a0156 | ||
|
|
d7a2132966 | ||
|
|
56ac1aea9d | ||
|
|
37a9fb62e2 | ||
|
|
6f9ce9ce85 | ||
|
|
b13cc6f39a |
@@ -1,5 +1,11 @@
|
|||||||
# sapper changelog
|
# sapper changelog
|
||||||
|
|
||||||
|
## 0.10.7
|
||||||
|
|
||||||
|
* Allow routes to have a leading `.` ([#243](https://github.com/sveltejs/sapper/pull/243))
|
||||||
|
* Only encode necessary characters in routes ([#234](https://github.com/sveltejs/sapper/pull/234))
|
||||||
|
* Preserve existing `process.env` when exporting ([#245](https://github.com/sveltejs/sapper/pull/245))
|
||||||
|
|
||||||
## 0.10.6
|
## 0.10.6
|
||||||
|
|
||||||
* Fix error reporting in `sapper start`
|
* Fix error reporting in `sapper start`
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sapper",
|
"name": "sapper",
|
||||||
"version": "0.10.6",
|
"version": "0.10.7",
|
||||||
"description": "Military-grade apps, engineered by Svelte",
|
"description": "Military-grade apps, engineered by Svelte",
|
||||||
"main": "dist/middleware.ts.js",
|
"main": "dist/middleware.ts.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
|||||||
@@ -35,12 +35,12 @@ export async function exporter(export_dir: string, { basepath = '' }) {
|
|||||||
|
|
||||||
const proc = child_process.fork(path.resolve(`${build_dir}/server.js`), [], {
|
const proc = child_process.fork(path.resolve(`${build_dir}/server.js`), [], {
|
||||||
cwd: process.cwd(),
|
cwd: process.cwd(),
|
||||||
env: {
|
env: Object.assign({
|
||||||
PORT: port,
|
PORT: port,
|
||||||
NODE_ENV: 'production',
|
NODE_ENV: 'production',
|
||||||
SAPPER_DEST: build_dir,
|
SAPPER_DEST: build_dir,
|
||||||
SAPPER_EXPORT: 'true'
|
SAPPER_EXPORT: 'true'
|
||||||
}
|
}, process.env)
|
||||||
});
|
});
|
||||||
|
|
||||||
const seen = new Set();
|
const seen = new Set();
|
||||||
@@ -103,4 +103,4 @@ export async function exporter(export_dir: string, { basepath = '' }) {
|
|||||||
return ports.wait(port)
|
return ports.wait(port)
|
||||||
.then(() => handle(new URL(`/${basepath}`, origin))) // TODO all static routes
|
.then(() => handle(new URL(`/${basepath}`, origin))) // TODO all static routes
|
||||||
.then(() => proc.kill());
|
.then(() => proc.kill());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import glob from 'glob';
|
|||||||
import { locations } from '../config';
|
import { locations } from '../config';
|
||||||
import { Route } from '../interfaces';
|
import { Route } from '../interfaces';
|
||||||
|
|
||||||
export default function create_routes({ files } = { files: glob.sync('**/*.*', { cwd: locations.routes(), nodir: true }) }) {
|
export default function create_routes({ files } = { files: glob.sync('**/*.*', { cwd: locations.routes(), dot: true, nodir: true }) }) {
|
||||||
const routes: Route[] = files
|
const routes: Route[] = files
|
||||||
.map((file: string) => {
|
.map((file: string) => {
|
||||||
if (/(^|\/|\\)_/.test(file)) return;
|
if (/(^|\/|\\)_/.test(file)) return;
|
||||||
@@ -33,7 +33,7 @@ export default function create_routes({ files } = { files: glob.sync('**/*.*', {
|
|||||||
let i = parts.length;
|
let i = parts.length;
|
||||||
let nested = true;
|
let nested = true;
|
||||||
while (i--) {
|
while (i--) {
|
||||||
const part = encodeURIComponent(parts[i].normalize()).replace(/%5B/g, '[').replace(/%5D/g, ']');
|
const part = encodeURI(parts[i].normalize()).replace(/\?/g, '%3F').replace(/#/g, '%23').replace(/%5B/g, '[').replace(/%5D/g, ']');
|
||||||
const dynamic = ~part.indexOf('[');
|
const dynamic = ~part.indexOf('[');
|
||||||
|
|
||||||
if (dynamic) {
|
if (dynamic) {
|
||||||
|
|||||||
@@ -2,6 +2,25 @@ const assert = require('assert');
|
|||||||
const { create_routes } = require('../../dist/core.ts.js');
|
const { create_routes } = require('../../dist/core.ts.js');
|
||||||
|
|
||||||
describe('create_routes', () => {
|
describe('create_routes', () => {
|
||||||
|
it('encodes caharcters not allowed in path', () => {
|
||||||
|
const routes = create_routes({
|
||||||
|
files: [
|
||||||
|
'"',
|
||||||
|
'#',
|
||||||
|
'?'
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.deepEqual(
|
||||||
|
routes.map(r => r.pattern),
|
||||||
|
[
|
||||||
|
/^\/%22\/?$/,
|
||||||
|
/^\/%23\/?$/,
|
||||||
|
/^\/%3F\/?$/
|
||||||
|
]
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it('sorts routes correctly', () => {
|
it('sorts routes correctly', () => {
|
||||||
const routes = create_routes({
|
const routes = create_routes({
|
||||||
files: ['index.html', 'about.html', 'post/f[xx].html', '[wildcard].html', 'post/foo.html', 'post/[id].html', 'post/bar.html', 'post/[id].json.js']
|
files: ['index.html', 'about.html', 'post/f[xx].html', '[wildcard].html', 'post/foo.html', 'post/[id].html', 'post/bar.html', 'post/[id].json.js']
|
||||||
|
|||||||
Reference in New Issue
Block a user