@spirobel/mininext 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/url.d.ts +12 -0
- package/dist/url.js +16 -0
- package/package.json +1 -1
package/dist/url.d.ts
CHANGED
|
@@ -152,6 +152,18 @@ export declare class url {
|
|
|
152
152
|
*/
|
|
153
153
|
static set<K extends string>(entries: [K, HtmlHandler][]): void;
|
|
154
154
|
static set(urlPath: string, handler: HtmlHandler): void;
|
|
155
|
+
/**
|
|
156
|
+
* use this to remove routes.
|
|
157
|
+
* @param urlPath - the route to remove
|
|
158
|
+
* @example
|
|
159
|
+
* ``` js
|
|
160
|
+
* let perma_link_defined_by_editor_or_admin_user_that_changed = "/haha"
|
|
161
|
+
* url.remove(perma_link_defined_by_editor_or_admin_user_that_changed);
|
|
162
|
+
* // add new url after removing the old one (that might come from a sqlite db)
|
|
163
|
+
* url.set("/huhu", (mini)=> mini.html`huhu`)
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
166
|
+
static remove(urlPath: string): void;
|
|
155
167
|
/**
|
|
156
168
|
* wrap your handlers in this if you mutate something to prevent CSRF issues.
|
|
157
169
|
* @param handler - normal html handler with mini as the argument
|
package/dist/url.js
CHANGED
|
@@ -188,6 +188,22 @@ export class url {
|
|
|
188
188
|
addUrl(entryUrl, entryHandler);
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
|
+
/**
|
|
192
|
+
* use this to remove routes.
|
|
193
|
+
* @param urlPath - the route to remove
|
|
194
|
+
* @example
|
|
195
|
+
* ``` js
|
|
196
|
+
* let perma_link_defined_by_editor_or_admin_user_that_changed = "/haha"
|
|
197
|
+
* url.remove(perma_link_defined_by_editor_or_admin_user_that_changed);
|
|
198
|
+
* // add new url after removing the old one (that might come from a sqlite db)
|
|
199
|
+
* url.set("/huhu", (mini)=> mini.html`huhu`)
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
static remove(urlPath) {
|
|
203
|
+
for (const u of url.generateVariations(urlPath)) {
|
|
204
|
+
url.direct_handlers_html.delete(u);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
191
207
|
/**
|
|
192
208
|
* wrap your handlers in this if you mutate something to prevent CSRF issues.
|
|
193
209
|
* @param handler - normal html handler with mini as the argument
|