@etsoo/appscript 1.2.95 → 1.2.97

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.
@@ -71,7 +71,7 @@ class CoreAppTest extends CoreApp<
71
71
  /**
72
72
  * App root url
73
73
  */
74
- homepage: '',
74
+ homepage: '/cms',
75
75
 
76
76
  /**
77
77
  * Web url of the cloud
@@ -125,6 +125,12 @@ class CoreAppTest extends CoreApp<
125
125
 
126
126
  const app = new CoreAppTest();
127
127
 
128
+ test('Tests for addRootUrl', () => {
129
+ expect(app.addRootUrl('/home')).toBe('/cms/home');
130
+ expect(app.addRootUrl('./home')).toBe('/cms/./home');
131
+ expect(app.addRootUrl('home')).toBe('/cms/home');
132
+ });
133
+
128
134
  test('Tests for encrypt / decrypt', () => {
129
135
  // Arrange
130
136
  const input = 'Hello, world!';
@@ -141,6 +141,12 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
141
141
  * @returns Result
142
142
  */
143
143
  protected addIdentifier(field: string): string;
144
+ /**
145
+ * Add root (homepage) to the URL
146
+ * @param url URL to add
147
+ * @returns Result
148
+ */
149
+ addRootUrl(url: string): string;
144
150
  /**
145
151
  * Restore settings from persisted source
146
152
  */
@@ -149,6 +149,21 @@ class CoreApp {
149
149
  addIdentifier(field) {
150
150
  return field + '-' + this.name;
151
151
  }
152
+ /**
153
+ * Add root (homepage) to the URL
154
+ * @param url URL to add
155
+ * @returns Result
156
+ */
157
+ addRootUrl(url) {
158
+ const page = this.settings.homepage;
159
+ const endSlash = page.endsWith('/');
160
+ return (page +
161
+ (endSlash
162
+ ? shared_1.Utils.trimStart(url, '/')
163
+ : url.startsWith('/')
164
+ ? url
165
+ : '/' + url));
166
+ }
152
167
  /**
153
168
  * Restore settings from persisted source
154
169
  */
@@ -129,6 +129,12 @@ export interface IApp {
129
129
  * Is screen size up 'md'
130
130
  */
131
131
  mdUp?: boolean;
132
+ /**
133
+ * Add root (homepage) to the URL
134
+ * @param url URL to add
135
+ * @returns Result
136
+ */
137
+ addRootUrl(url: string): string;
132
138
  /**
133
139
  * Alert action result
134
140
  * @param result Action result
@@ -141,6 +141,12 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
141
141
  * @returns Result
142
142
  */
143
143
  protected addIdentifier(field: string): string;
144
+ /**
145
+ * Add root (homepage) to the URL
146
+ * @param url URL to add
147
+ * @returns Result
148
+ */
149
+ addRootUrl(url: string): string;
144
150
  /**
145
151
  * Restore settings from persisted source
146
152
  */
@@ -146,6 +146,21 @@ export class CoreApp {
146
146
  addIdentifier(field) {
147
147
  return field + '-' + this.name;
148
148
  }
149
+ /**
150
+ * Add root (homepage) to the URL
151
+ * @param url URL to add
152
+ * @returns Result
153
+ */
154
+ addRootUrl(url) {
155
+ const page = this.settings.homepage;
156
+ const endSlash = page.endsWith('/');
157
+ return (page +
158
+ (endSlash
159
+ ? Utils.trimStart(url, '/')
160
+ : url.startsWith('/')
161
+ ? url
162
+ : '/' + url));
163
+ }
149
164
  /**
150
165
  * Restore settings from persisted source
151
166
  */
@@ -129,6 +129,12 @@ export interface IApp {
129
129
  * Is screen size up 'md'
130
130
  */
131
131
  mdUp?: boolean;
132
+ /**
133
+ * Add root (homepage) to the URL
134
+ * @param url URL to add
135
+ * @returns Result
136
+ */
137
+ addRootUrl(url: string): string;
132
138
  /**
133
139
  * Alert action result
134
140
  * @param result Action result
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.2.95",
3
+ "version": "1.2.97",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -54,7 +54,7 @@
54
54
  "dependencies": {
55
55
  "@etsoo/notificationbase": "^1.1.7",
56
56
  "@etsoo/restclient": "^1.0.73",
57
- "@etsoo/shared": "^1.1.57",
57
+ "@etsoo/shared": "^1.1.58",
58
58
  "@types/crypto-js": "^4.1.1",
59
59
  "crypto-js": "^4.1.1"
60
60
  },
@@ -65,14 +65,14 @@
65
65
  "@babel/preset-env": "^7.19.1",
66
66
  "@babel/runtime-corejs3": "^7.19.1",
67
67
  "@types/jest": "^29.0.3",
68
- "@typescript-eslint/eslint-plugin": "^5.37.0",
69
- "@typescript-eslint/parser": "^5.37.0",
70
- "eslint": "^8.23.1",
68
+ "@typescript-eslint/eslint-plugin": "^5.38.0",
69
+ "@typescript-eslint/parser": "^5.38.0",
70
+ "eslint": "^8.24.0",
71
71
  "eslint-config-airbnb-base": "^15.0.0",
72
72
  "eslint-plugin-import": "^2.26.0",
73
73
  "jest": "^29.0.3",
74
74
  "jest-environment-jsdom": "^29.0.3",
75
- "ts-jest": "^29.0.1",
75
+ "ts-jest": "^29.0.2",
76
76
  "typescript": "^4.8.3"
77
77
  }
78
78
  }
@@ -303,6 +303,24 @@ export abstract class CoreApp<
303
303
  return field + '-' + this.name;
304
304
  }
305
305
 
306
+ /**
307
+ * Add root (homepage) to the URL
308
+ * @param url URL to add
309
+ * @returns Result
310
+ */
311
+ addRootUrl(url: string) {
312
+ const page = this.settings.homepage;
313
+ const endSlash = page.endsWith('/');
314
+ return (
315
+ page +
316
+ (endSlash
317
+ ? Utils.trimStart(url, '/')
318
+ : url.startsWith('/')
319
+ ? url
320
+ : '/' + url)
321
+ );
322
+ }
323
+
306
324
  /**
307
325
  * Restore settings from persisted source
308
326
  */
package/src/app/IApp.ts CHANGED
@@ -170,6 +170,13 @@ export interface IApp {
170
170
  */
171
171
  mdUp?: boolean;
172
172
 
173
+ /**
174
+ * Add root (homepage) to the URL
175
+ * @param url URL to add
176
+ * @returns Result
177
+ */
178
+ addRootUrl(url: string): string;
179
+
173
180
  /**
174
181
  * Alert action result
175
182
  * @param result Action result