Accept . as a query string delimiter.
This commit is contained in:
+4
-2
@@ -749,7 +749,7 @@ class FrigateCard extends LitElement {
|
||||
// the default view and the querystring view, see:
|
||||
// https://github.com/dermotduffy/frigate-hass-card/issues/1200
|
||||
if (!this._view) {
|
||||
const querystringActions = getActionsFromQueryString();
|
||||
const querystringActions = getActionsFromQueryString(window.location.search);
|
||||
if (
|
||||
!querystringActions.find(
|
||||
(action) =>
|
||||
@@ -1594,7 +1594,9 @@ class FrigateCard extends LitElement {
|
||||
protected _locationChangeHandler = (): void => {
|
||||
// Only execute actions when the card has rendered at least once.
|
||||
if (this.hasUpdated) {
|
||||
getActionsFromQueryString().forEach((action) => this._cardActionHandler(action));
|
||||
getActionsFromQueryString(window.location.search).forEach((action) =>
|
||||
this._cardActionHandler(action),
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+4
-1
@@ -217,7 +217,10 @@ const frigateCardCustomActionsBaseSchema = customActionSchema.extend({
|
||||
.or(z.literal('fire-dom-event')),
|
||||
|
||||
// Card this command is intended for.
|
||||
card_id: z.string().optional(),
|
||||
card_id: z
|
||||
.string()
|
||||
.regex(/^\w+$/, 'card_id parameter can only contain [a-z][A-Z][0-9_]')
|
||||
.optional(),
|
||||
});
|
||||
|
||||
const FRIGATE_CARD_GENERAL_ACTIONS = [
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
import { FrigateCardCustomAction } from '../types';
|
||||
import { createFrigateCardCustomAction } from './action.js';
|
||||
|
||||
export const getActionsFromQueryString = (): FrigateCardCustomAction[] => {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
export const getActionsFromQueryString = (
|
||||
queryString: string,
|
||||
): FrigateCardCustomAction[] => {
|
||||
const params = new URLSearchParams(queryString);
|
||||
const actions: FrigateCardCustomAction[] = [];
|
||||
const actionRE = new RegExp(/^frigate-card-action(:(?<cardID>\w+))?:(?<action>\w+)/);
|
||||
|
||||
const actionRE = new RegExp(
|
||||
/^frigate-card-action([.:](?<cardID>\w+))?[.:](?<action>\w+)/,
|
||||
);
|
||||
for (const [key, value] of params.entries()) {
|
||||
const match = key.match(actionRE);
|
||||
if (!match || !match.groups) {
|
||||
|
||||
Reference in New Issue
Block a user