feat: support static uri's with paths (#2399)

This commit is contained in:
Wyatt Johnson
2019-07-12 19:11:11 +00:00
committed by GitHub
parent 0b20542f05
commit b5b9cb7e2f
4 changed files with 13 additions and 11 deletions
+5
View File
@@ -499,6 +499,11 @@ export default function createWebpackConfig(
exclude: [/\.(js|ts|tsx)$/, /\.html$/, /\.json$/],
loader: require.resolve("file-loader"),
options: {
// Because the resources loaded via CSS can sometimes be loaded
// directly from a CSS file, this will ensure that they are
// relative to those referencing files.
publicPath: (loaderPublicPath: string) =>
"../../" + loaderPublicPath,
name: isProduction
? "assets/media/[name].[hash:8].[ext]"
: "assets/media/[name].[ext]",
+1 -5
View File
@@ -70,11 +70,7 @@ export default class Entrypoints {
// Check to see if the asset is a match.
if (asset.src === src) {
entrypoint[extension].push({
integrity: asset.integrity,
// Prefix all the sources with a `/`.
src: "/" + asset.src,
});
entrypoint[extension].push(asset);
break;
}
}
+3 -1
View File
@@ -31,7 +31,9 @@ export function createRouter(app: AppOptions, options: RouterOptions) {
if (!options.disableClientRoutes) {
mountClientRoutes(router, {
staticURI: app.config.get("static_uri"),
// When mounting client routes, we need to provide a staticURI even when
// not provided to the default current domain relative "/".
staticURI: app.config.get("static_uri") || "/",
tenantCache: app.tenantCache,
});
} else {
+4 -5
View File
@@ -4,6 +4,7 @@ import { parseConnectionString } from "mongodb-core";
import os from "os";
import { LOCALES } from "coral-common/helpers/i18n/locales";
import { ensureEndSlash } from "coral-common/utils";
import { InternalError } from "./errors";
@@ -32,7 +33,7 @@ convict.addFormat({
},
});
// Add a custom format for the optional-url.
// Add a custom format for the optional-url that includes a trailing slash.
convict.addFormat({
name: "optional-url",
validate: (url: string) => {
@@ -40,10 +41,8 @@ convict.addFormat({
Joi.assert(url, Joi.string().uri());
}
},
// Ensure that there is no ending slash.
coerce: (url: string) => {
return url.replace(/\/$/, "");
},
// Ensure that there is an ending slash.
coerce: (url: string) => (url ? ensureEndSlash(url) : url),
});
const config = convict({