diff --git a/CHANGELOG.md b/CHANGELOG.md index 07713aeb..6a64f89d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +## 0.3.2 (2024-12-11) + ### Fixes - Make the logic to find reachable sites less strict diff --git a/assets/package-lock.json b/assets/package-lock.json index fb3ed326..3c82d017 100644 --- a/assets/package-lock.json +++ b/assets/package-lock.json @@ -1,12 +1,12 @@ { "name": "beacon", - "version": "0.3.1", + "version": "0.3.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "beacon", - "version": "0.3.1", + "version": "0.3.2", "license": "MIT", "dependencies": { "@tailwindcss/forms": "^0.5", diff --git a/assets/package.json b/assets/package.json index 02492734..1f8fee19 100644 --- a/assets/package.json +++ b/assets/package.json @@ -1,6 +1,6 @@ { "name": "beacon", - "version": "0.3.1", + "version": "0.3.2", "license": "MIT", "repository": {}, "scripts": { diff --git a/lib/beacon/router.ex b/lib/beacon/router.ex index d5d1cd44..debb1224 100644 --- a/lib/beacon/router.ex +++ b/lib/beacon/router.ex @@ -145,6 +145,9 @@ defmodule Beacon.Router do get "/__beacon_assets__/css-:md5", Beacon.Web.AssetsController, :css, assigns: %{site: opts[:site]} get "/__beacon_assets__/js-:md5", Beacon.Web.AssetsController, :js, assigns: %{site: opts[:site]} + # simulate a beacon page inside site prefix so we can check this site is reachable?/2 + get "/__beacon_check__", Beacon.Web.CheckController, :check, metadata: %{site: opts[:site]} + live "/*path", Beacon.Web.PageLive, :path end end @@ -250,27 +253,13 @@ defmodule Beacon.Router do @doc false # Tells if a `beacon_site` is reachable in the current environment. # - # Supposed the following router: - # - # scope "/", MyAppWeb, host: ["beacon-site-a.fly.dev"] do - # pipe_through [:browser] - # beacon_site "/", site: :site_a - # end - # - # scope "/", MyAppWeb, host: ["beacon-site-b.fly.dev"] do - # pipe_through [:browser] - # beacon_site "/", site: :site_b - # end - # - # On a node deployed to beacon-site-a.fly.dev, the second `beacon_site` - # will never match, so starting `:site_b` is a waste of resources - # and a common cause of problems on BeaconLiveAdmin since we can't resolve URLs properly. - # - # Similarly, if a `get "/"` is added _before_ either `beacon_site` that `get` would always - # match and invalidate the `beacon_site` mount. + # It's considered reachable if a dynamic page can be served on the site prefix. def reachable?(%Beacon.Config{} = config, opts \\ []) do %{site: site, endpoint: endpoint, router: router} = config - function_exported?(router, :__beacon_scoped_prefix_for_site__, 1) && reachable?(site, endpoint, router, opts) + reachable?(site, endpoint, router, opts) + rescue + # missing router or missing beacon macros in the router + _ -> false end defp reachable?(site, endpoint, router, opts) do @@ -281,14 +270,10 @@ defmodule Beacon.Router do router.__beacon_scoped_prefix_for_site__(site) end) - case Phoenix.Router.route_info(router, "GET", prefix, host) do - # bypass and allow booting beacon sites even though there's a route conflict - # but only for root paths, for example: - # live / - # beacon_site / - # that's because even though they share the same prefix, - # beacon can still serve pages at /:page - %{route: "/"} -> + path = Beacon.Router.sanitize_path(prefix <> "/__beacon_check__") + + case Phoenix.Router.route_info(router, "GET", path, host) do + %{site: ^site, plug: Beacon.Web.CheckController} -> true %{phoenix_live_view: {Beacon.Web.PageLive, _, _, %{extra: %{session: %{"beacon_site" => ^site}}}}} -> diff --git a/lib/beacon/web/controllers/check_controller.ex b/lib/beacon/web/controllers/check_controller.ex new file mode 100644 index 00000000..9a469052 --- /dev/null +++ b/lib/beacon/web/controllers/check_controller.ex @@ -0,0 +1,16 @@ +defmodule Beacon.Web.CheckController do + @moduledoc false + # TODO: replace CheckController with a plug in https://github.com/BeaconCMS/beacon/pull/694 + + import Plug.Conn + + def init(conn), do: conn + + def call(conn, _) do + conn + |> put_resp_header("content-type", "text/plain") + |> put_resp_header("cache-control", "public, max-age=31536000, immutable") + |> send_resp(200, "") + |> halt() + end +end diff --git a/mix.exs b/mix.exs index f6cfde54..20756acf 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ defmodule Beacon.MixProject do use Mix.Project - @version "0.3.1" + @version "0.3.2" @source_url "https://github.com/BeaconCMS/beacon" @homepage_url "https://beaconcms.org" diff --git a/priv/tailwind.config.bundle.js b/priv/tailwind.config.bundle.js index bfa66f72..2b40ddc8 100644 --- a/priv/tailwind.config.bundle.js +++ b/priv/tailwind.config.bundle.js @@ -1319,7 +1319,7 @@ var require_picocolors_browser = __commonJS({ "node_modules/picocolors/picocolors.browser.js"(exports, module) { var x = String; var create = function() { - return { isColorSupported: false, reset: x, bold: x, dim: x, italic: x, underline: x, inverse: x, hidden: x, strikethrough: x, black: x, red: x, green: x, yellow: x, blue: x, magenta: x, cyan: x, white: x, gray: x, bgBlack: x, bgRed: x, bgGreen: x, bgYellow: x, bgBlue: x, bgMagenta: x, bgCyan: x, bgWhite: x }; + return { isColorSupported: false, reset: x, bold: x, dim: x, italic: x, underline: x, inverse: x, hidden: x, strikethrough: x, black: x, red: x, green: x, yellow: x, blue: x, magenta: x, cyan: x, white: x, gray: x, bgBlack: x, bgRed: x, bgGreen: x, bgYellow: x, bgBlue: x, bgMagenta: x, bgCyan: x, bgWhite: x, blackBright: x, redBright: x, greenBright: x, yellowBright: x, blueBright: x, magentaBright: x, cyanBright: x, whiteBright: x, bgBlackBright: x, bgRedBright: x, bgGreenBright: x, bgYellowBright: x, bgBlueBright: x, bgMagentaBright: x, bgCyanBright: x, bgWhiteBright: x }; }; module.exports = create(); module.exports.createColors = create; @@ -1776,6 +1776,13 @@ var require_src = __commonJS({ } var forms = plugin2.withOptions(function(options = { strategy: void 0 }) { return function({ addBase, addComponents, theme }) { + function resolveChevronColor(color, fallback) { + let resolved = theme(color); + if (!resolved || resolved.includes("var(")) { + return fallback; + } + return resolved.replace("", "1"); + } const strategy = options.strategy === void 0 ? ["base", "class"] : [options.strategy]; const rules = [ { @@ -1917,9 +1924,9 @@ var require_src = __commonJS({ class: [".form-select"], styles: { "background-image": `url("${svgToDataUri( - `` )}")`, "background-position": `right ${spacing[2]} center`, @@ -4411,7 +4418,6 @@ var require_styles = __commonJS({ table: { width: "100%", tableLayout: "auto", - textAlign: "start", marginTop: em(32, 16), marginBottom: em(32, 16) }, @@ -4441,6 +4447,9 @@ var require_styles = __commonJS({ "tfoot td": { verticalAlign: "top" }, + "th, td": { + textAlign: "start" + }, "figure > *": {}, // Required to maintain correct order when merging figcaption: { @@ -4500,9 +4509,9 @@ var require_lodash3 = __commonJS({ } }); -// node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/util/unesc.js +// node_modules/postcss-selector-parser/dist/util/unesc.js var require_unesc = __commonJS({ - "node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/util/unesc.js"(exports, module) { + "node_modules/postcss-selector-parser/dist/util/unesc.js"(exports, module) { "use strict"; exports.__esModule = true; exports["default"] = unesc; @@ -4562,9 +4571,9 @@ var require_unesc = __commonJS({ } }); -// node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/util/getProp.js +// node_modules/postcss-selector-parser/dist/util/getProp.js var require_getProp = __commonJS({ - "node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/util/getProp.js"(exports, module) { + "node_modules/postcss-selector-parser/dist/util/getProp.js"(exports, module) { "use strict"; exports.__esModule = true; exports["default"] = getProp; @@ -4585,9 +4594,9 @@ var require_getProp = __commonJS({ } }); -// node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/util/ensureObject.js +// node_modules/postcss-selector-parser/dist/util/ensureObject.js var require_ensureObject = __commonJS({ - "node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/util/ensureObject.js"(exports, module) { + "node_modules/postcss-selector-parser/dist/util/ensureObject.js"(exports, module) { "use strict"; exports.__esModule = true; exports["default"] = ensureObject; @@ -4607,9 +4616,9 @@ var require_ensureObject = __commonJS({ } }); -// node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/util/stripComments.js +// node_modules/postcss-selector-parser/dist/util/stripComments.js var require_stripComments = __commonJS({ - "node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/util/stripComments.js"(exports, module) { + "node_modules/postcss-selector-parser/dist/util/stripComments.js"(exports, module) { "use strict"; exports.__esModule = true; exports["default"] = stripComments; @@ -4633,9 +4642,9 @@ var require_stripComments = __commonJS({ } }); -// node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/util/index.js +// node_modules/postcss-selector-parser/dist/util/index.js var require_util = __commonJS({ - "node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/util/index.js"(exports) { + "node_modules/postcss-selector-parser/dist/util/index.js"(exports) { "use strict"; exports.__esModule = true; exports.stripComments = exports.ensureObject = exports.getProp = exports.unesc = void 0; @@ -4653,9 +4662,9 @@ var require_util = __commonJS({ } }); -// node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/selectors/node.js +// node_modules/postcss-selector-parser/dist/selectors/node.js var require_node = __commonJS({ - "node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/selectors/node.js"(exports, module) { + "node_modules/postcss-selector-parser/dist/selectors/node.js"(exports, module) { "use strict"; exports.__esModule = true; exports["default"] = void 0; @@ -4829,9 +4838,9 @@ var require_node = __commonJS({ } }); -// node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/selectors/types.js +// node_modules/postcss-selector-parser/dist/selectors/types.js var require_types = __commonJS({ - "node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/selectors/types.js"(exports) { + "node_modules/postcss-selector-parser/dist/selectors/types.js"(exports) { "use strict"; exports.__esModule = true; exports.UNIVERSAL = exports.ATTRIBUTE = exports.CLASS = exports.COMBINATOR = exports.COMMENT = exports.ID = exports.NESTING = exports.PSEUDO = exports.ROOT = exports.SELECTOR = exports.STRING = exports.TAG = void 0; @@ -4862,9 +4871,9 @@ var require_types = __commonJS({ } }); -// node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/selectors/container.js +// node_modules/postcss-selector-parser/dist/selectors/container.js var require_container = __commonJS({ - "node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/selectors/container.js"(exports, module) { + "node_modules/postcss-selector-parser/dist/selectors/container.js"(exports, module) { "use strict"; exports.__esModule = true; exports["default"] = void 0; @@ -5248,9 +5257,9 @@ var require_container = __commonJS({ } }); -// node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/selectors/root.js +// node_modules/postcss-selector-parser/dist/selectors/root.js var require_root = __commonJS({ - "node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/selectors/root.js"(exports, module) { + "node_modules/postcss-selector-parser/dist/selectors/root.js"(exports, module) { "use strict"; exports.__esModule = true; exports["default"] = void 0; @@ -5321,9 +5330,9 @@ var require_root = __commonJS({ } }); -// node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/selectors/selector.js +// node_modules/postcss-selector-parser/dist/selectors/selector.js var require_selector = __commonJS({ - "node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/selectors/selector.js"(exports, module) { + "node_modules/postcss-selector-parser/dist/selectors/selector.js"(exports, module) { "use strict"; exports.__esModule = true; exports["default"] = void 0; @@ -5449,9 +5458,9 @@ var require_cssesc = __commonJS({ } }); -// node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/selectors/className.js +// node_modules/postcss-selector-parser/dist/selectors/className.js var require_className = __commonJS({ - "node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/selectors/className.js"(exports, module) { + "node_modules/postcss-selector-parser/dist/selectors/className.js"(exports, module) { "use strict"; exports.__esModule = true; exports["default"] = void 0; @@ -5528,9 +5537,9 @@ var require_className = __commonJS({ } }); -// node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/selectors/comment.js +// node_modules/postcss-selector-parser/dist/selectors/comment.js var require_comment = __commonJS({ - "node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/selectors/comment.js"(exports, module) { + "node_modules/postcss-selector-parser/dist/selectors/comment.js"(exports, module) { "use strict"; exports.__esModule = true; exports["default"] = void 0; @@ -5566,9 +5575,9 @@ var require_comment = __commonJS({ } }); -// node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/selectors/id.js +// node_modules/postcss-selector-parser/dist/selectors/id.js var require_id = __commonJS({ - "node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/selectors/id.js"(exports, module) { + "node_modules/postcss-selector-parser/dist/selectors/id.js"(exports, module) { "use strict"; exports.__esModule = true; exports["default"] = void 0; @@ -5608,9 +5617,9 @@ var require_id = __commonJS({ } }); -// node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/selectors/namespace.js +// node_modules/postcss-selector-parser/dist/selectors/namespace.js var require_namespace = __commonJS({ - "node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/selectors/namespace.js"(exports, module) { + "node_modules/postcss-selector-parser/dist/selectors/namespace.js"(exports, module) { "use strict"; exports.__esModule = true; exports["default"] = void 0; @@ -5716,9 +5725,9 @@ var require_namespace = __commonJS({ } }); -// node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/selectors/tag.js +// node_modules/postcss-selector-parser/dist/selectors/tag.js var require_tag = __commonJS({ - "node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/selectors/tag.js"(exports, module) { + "node_modules/postcss-selector-parser/dist/selectors/tag.js"(exports, module) { "use strict"; exports.__esModule = true; exports["default"] = void 0; @@ -5754,9 +5763,9 @@ var require_tag = __commonJS({ } }); -// node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/selectors/string.js +// node_modules/postcss-selector-parser/dist/selectors/string.js var require_string = __commonJS({ - "node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/selectors/string.js"(exports, module) { + "node_modules/postcss-selector-parser/dist/selectors/string.js"(exports, module) { "use strict"; exports.__esModule = true; exports["default"] = void 0; @@ -5792,9 +5801,9 @@ var require_string = __commonJS({ } }); -// node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/selectors/pseudo.js +// node_modules/postcss-selector-parser/dist/selectors/pseudo.js var require_pseudo = __commonJS({ - "node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/selectors/pseudo.js"(exports, module) { + "node_modules/postcss-selector-parser/dist/selectors/pseudo.js"(exports, module) { "use strict"; exports.__esModule = true; exports["default"] = void 0; @@ -5872,9 +5881,9 @@ var require_browser = __commonJS({ } }); -// node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/selectors/attribute.js +// node_modules/postcss-selector-parser/dist/selectors/attribute.js var require_attribute = __commonJS({ - "node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/selectors/attribute.js"(exports) { + "node_modules/postcss-selector-parser/dist/selectors/attribute.js"(exports) { "use strict"; exports.__esModule = true; exports.unescapeValue = unescapeValue; @@ -6237,9 +6246,9 @@ var require_attribute = __commonJS({ } }); -// node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/selectors/universal.js +// node_modules/postcss-selector-parser/dist/selectors/universal.js var require_universal = __commonJS({ - "node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/selectors/universal.js"(exports, module) { + "node_modules/postcss-selector-parser/dist/selectors/universal.js"(exports, module) { "use strict"; exports.__esModule = true; exports["default"] = void 0; @@ -6276,9 +6285,9 @@ var require_universal = __commonJS({ } }); -// node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/selectors/combinator.js +// node_modules/postcss-selector-parser/dist/selectors/combinator.js var require_combinator = __commonJS({ - "node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/selectors/combinator.js"(exports, module) { + "node_modules/postcss-selector-parser/dist/selectors/combinator.js"(exports, module) { "use strict"; exports.__esModule = true; exports["default"] = void 0; @@ -6314,9 +6323,9 @@ var require_combinator = __commonJS({ } }); -// node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/selectors/nesting.js +// node_modules/postcss-selector-parser/dist/selectors/nesting.js var require_nesting = __commonJS({ - "node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/selectors/nesting.js"(exports, module) { + "node_modules/postcss-selector-parser/dist/selectors/nesting.js"(exports, module) { "use strict"; exports.__esModule = true; exports["default"] = void 0; @@ -6353,9 +6362,9 @@ var require_nesting = __commonJS({ } }); -// node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/sortAscending.js +// node_modules/postcss-selector-parser/dist/sortAscending.js var require_sortAscending = __commonJS({ - "node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/sortAscending.js"(exports, module) { + "node_modules/postcss-selector-parser/dist/sortAscending.js"(exports, module) { "use strict"; exports.__esModule = true; exports["default"] = sortAscending; @@ -6368,9 +6377,9 @@ var require_sortAscending = __commonJS({ } }); -// node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/tokenTypes.js +// node_modules/postcss-selector-parser/dist/tokenTypes.js var require_tokenTypes = __commonJS({ - "node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/tokenTypes.js"(exports) { + "node_modules/postcss-selector-parser/dist/tokenTypes.js"(exports) { "use strict"; exports.__esModule = true; exports.combinator = exports.word = exports.comment = exports.str = exports.tab = exports.newline = exports.feed = exports.cr = exports.backslash = exports.bang = exports.slash = exports.doubleQuote = exports.singleQuote = exports.space = exports.greaterThan = exports.pipe = exports.equals = exports.plus = exports.caret = exports.tilde = exports.dollar = exports.closeSquare = exports.openSquare = exports.closeParenthesis = exports.openParenthesis = exports.semicolon = exports.colon = exports.comma = exports.at = exports.asterisk = exports.ampersand = void 0; @@ -6439,9 +6448,9 @@ var require_tokenTypes = __commonJS({ } }); -// node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/tokenize.js +// node_modules/postcss-selector-parser/dist/tokenize.js var require_tokenize = __commonJS({ - "node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/tokenize.js"(exports) { + "node_modules/postcss-selector-parser/dist/tokenize.js"(exports) { "use strict"; exports.__esModule = true; exports["default"] = tokenize; @@ -6697,9 +6706,9 @@ var require_tokenize = __commonJS({ } }); -// node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/parser.js +// node_modules/postcss-selector-parser/dist/parser.js var require_parser = __commonJS({ - "node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/parser.js"(exports, module) { + "node_modules/postcss-selector-parser/dist/parser.js"(exports, module) { "use strict"; exports.__esModule = true; exports["default"] = void 0; @@ -7707,9 +7716,9 @@ var require_parser = __commonJS({ } }); -// node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/processor.js +// node_modules/postcss-selector-parser/dist/processor.js var require_processor = __commonJS({ - "node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/processor.js"(exports, module) { + "node_modules/postcss-selector-parser/dist/processor.js"(exports, module) { "use strict"; exports.__esModule = true; exports["default"] = void 0; @@ -7837,9 +7846,9 @@ var require_processor = __commonJS({ } }); -// node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/selectors/constructors.js +// node_modules/postcss-selector-parser/dist/selectors/constructors.js var require_constructors = __commonJS({ - "node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/selectors/constructors.js"(exports) { + "node_modules/postcss-selector-parser/dist/selectors/constructors.js"(exports) { "use strict"; exports.__esModule = true; exports.universal = exports.tag = exports.string = exports.selector = exports.root = exports.pseudo = exports.nesting = exports.id = exports.comment = exports.combinator = exports.className = exports.attribute = void 0; @@ -7909,9 +7918,9 @@ var require_constructors = __commonJS({ } }); -// node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/selectors/guards.js +// node_modules/postcss-selector-parser/dist/selectors/guards.js var require_guards = __commonJS({ - "node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/selectors/guards.js"(exports) { + "node_modules/postcss-selector-parser/dist/selectors/guards.js"(exports) { "use strict"; exports.__esModule = true; exports.isNode = isNode; @@ -7968,9 +7977,9 @@ var require_guards = __commonJS({ } }); -// node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/selectors/index.js +// node_modules/postcss-selector-parser/dist/selectors/index.js var require_selectors = __commonJS({ - "node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/selectors/index.js"(exports) { + "node_modules/postcss-selector-parser/dist/selectors/index.js"(exports) { "use strict"; exports.__esModule = true; var _types = require_types(); @@ -7994,9 +8003,9 @@ var require_selectors = __commonJS({ } }); -// node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/index.js +// node_modules/postcss-selector-parser/dist/index.js var require_dist = __commonJS({ - "node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser/dist/index.js"(exports, module) { + "node_modules/postcss-selector-parser/dist/index.js"(exports, module) { "use strict"; exports.__esModule = true; exports["default"] = void 0; diff --git a/test/beacon/router_test.exs b/test/beacon/router_test.exs index 25833863..8e5c2538 100644 --- a/test/beacon/router_test.exs +++ b/test/beacon/router_test.exs @@ -63,32 +63,35 @@ defmodule Beacon.RouterTest do end describe "reachable?" do - setup do - site = :host_test - config = Beacon.Config.fetch!(site) - [config: config] + defp config(site, opts \\ []) do + Map.merge( + Beacon.Config.fetch!(site), + Enum.into(opts, %{router: Beacon.BeaconTest.ReachTestRouter}) + ) end - test "match existing host", %{config: config} do - valid_host = "host.com" - assert Router.reachable?(config, host: valid_host) + test "match existing host" do + config = config(:host_test) + assert Router.reachable?(config, host: "host.com", prefix: "/host_test") end - test "existing nested conflicting route", %{config: config} do - valid_host = "host.com" - refute Router.reachable?(config, host: valid_host, prefix: "/nested/some_page") + test "existing nested conflicting route" do + config = config(:not_booted) + refute Router.reachable?(config, host: nil, prefix: "/conflict") end - test "with no specific host", %{config: config} do + test "root path with no host" do + config = config(:my_site) assert Router.reachable?(config, host: nil) end - test "do not match any existing host/path", %{config: config} do - refute Router.reachable?(config, host: nil, prefix: "/nested/invalid") + test "not reachable when does not match any existing host/path" do + config = config(:my_site) + refute Router.reachable?(config, host: nil, prefix: "/other") end test "router without beacon routes" do - config = Beacon.Config.fetch!(:no_routes) + config = config(:my_site, router: Beacon.BeaconTest.NoRoutesRouter) refute Router.reachable?(config) end end diff --git a/test/support/routers.ex b/test/support/routers.ex index e4c97810..a23befc3 100644 --- a/test/support/routers.ex +++ b/test/support/routers.ex @@ -2,7 +2,7 @@ defmodule Beacon.BeaconTest.NoRoutesRouter do use Beacon.BeaconTest.Web, :router end -defmodule Beacon.BeaconTest.Router do +defmodule Beacon.BeaconTest.ReachTestRouter do use Beacon.BeaconTest.Web, :router use Beacon.Router @@ -14,24 +14,43 @@ defmodule Beacon.BeaconTest.Router do plug :put_secure_browser_headers end - scope "/nested" do + scope path: "/host_test", host: "host.com" do pipe_through :browser - beacon_site "/site", site: :booted - beacon_site "/media", site: :s3_site + beacon_site "/", site: :host_test end - scope "/" do + scope path: "/conflict" do pipe_through :browser + live "/:page", Beacon.BeaconTest.LiveViews.FooBarLive + beacon_site "/", site: :not_booted + end - live_session :default do - live "/", Beacon.BeaconTest.LiveViews.FooBarLive - live "/nested/:page", Beacon.BeaconTest.LiveViews.FooBarLive - end + scope path: "/my_site" do + pipe_through :browser + beacon_site "/", site: :my_site end - scope path: "/", host: "host.com" do + scope path: "/other" do pipe_through :browser - beacon_site "/", site: :host_test + end +end + +defmodule Beacon.BeaconTest.Router do + use Beacon.BeaconTest.Web, :router + use Beacon.Router + + pipeline :browser do + plug :accepts, ["html"] + plug :fetch_session + plug :fetch_live_flash + plug :protect_from_forgery + plug :put_secure_browser_headers + end + + scope "/nested" do + pipe_through :browser + beacon_site "/site", site: :booted + beacon_site "/media", site: :s3_site end # `alias` is not really used but is present here to verify that `beacon_site` has no conflicts with custom aliases