Change naming function

This commit is contained in:
2023-09-11 14:02:05 +07:00
parent 409cba5b8f
commit 6e243bdf23
2 changed files with 14 additions and 6 deletions
+12 -4
View File
@@ -63,10 +63,18 @@ export const convertDataObjectToModel = (data) => {
return { id, ...object.data };
};
export const getURL = () => {
export const getSubdirectoryURL = () => {
const url = window.location.href;
const parts = url.split('/');
const lastPart = parts.pop(); // Lấy phần tử cuối cùng trong mảng
return lastPart;
const parts = url.split('/'); // Results: ['http:', '', 'example.com', '']
const subDirectory = parts[3]; // Get subdirectory url only
// Remove query behind subDirectory
const index = subDirectory.indexOf('?');
if (index !== -1) {
return subDirectory.substring(0, index);
}
return subDirectory;
};
+2 -2
View File
@@ -1,11 +1,11 @@
import RegisterView from './registerView';
import LoginView from './loginView';
import { getURL } from '../helpers/helpers';
import { getSubdirectoryURL } from '../helpers/helpers';
import { URL } from '../constants/constant';
export default class View {
constructor() {
switch (getURL()) {
switch (getSubdirectoryURL()) {
case URL.LOGIN:
this.loginView = new LoginView();
break;