diff --git a/README.md b/README.md index efb025c..343eb4d 100644 --- a/README.md +++ b/README.md @@ -238,6 +238,13 @@ Example: ### Route It's the [react-router-dom](https://reactrouter.com/en/main/route/route#type-declaration) `` component, same props, same usage. 😄 +### In-depth example +The recommended way to go to handle window states between main and renderer process (like creating or closing a new window) is using [IPC](https://www.electronjs.org/docs/latest/tutorial/ipc). You can check the [electron-app](https://github.com/daltonmenezes/electron-app) boilerplate to see how it was achieved, like: + +- [A preload script requesting window creation using IPC](https://github.com/daltonmenezes/electron-app/blob/main/src/preload/ipcs/windows/about/create.ts) +- [A window creation on main process using IPC](https://github.com/daltonmenezes/electron-app/blob/main/src/main/windows/About/ipcs/register-window-creation.ts) +- [The Routing doc from electron-app boilerplate](https://github.com/daltonmenezes/electron-app/blob/main/docs/ROUTING.md) + # Contributing > **Note**: contributions are always welcome, but always **ask first**, — please — before work on a PR. diff --git a/package.json b/package.json index 248f90e..a74610e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "electron-router-dom", - "version": "1.0.2", + "version": "1.0.4", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", "types": "dist/index.d.ts", diff --git a/src/main/modules/routes/create-url.ts b/src/main/modules/routes/create-url.ts index b39f1a0..55bda8f 100644 --- a/src/main/modules/routes/create-url.ts +++ b/src/main/modules/routes/create-url.ts @@ -1,3 +1,7 @@ +import { removeURLExtraDoubleSlashes } from '../../../shared' + export function createURLRoute(route: string, id: string) { - return `${route}/#/${id}` + const URL = `${route}/#/${id}` + + return removeURLExtraDoubleSlashes(URL) } diff --git a/src/shared/index.ts b/src/shared/index.ts index 0611ef6..549e396 100644 --- a/src/shared/index.ts +++ b/src/shared/index.ts @@ -1 +1,2 @@ +export * from './utils/remove-url-extra-double-slashes' export * from './utils/to-lower-case-keys' diff --git a/src/shared/utils/remove-url-extra-double-slashes.ts b/src/shared/utils/remove-url-extra-double-slashes.ts new file mode 100644 index 0000000..df68dba --- /dev/null +++ b/src/shared/utils/remove-url-extra-double-slashes.ts @@ -0,0 +1,3 @@ +export function removeURLExtraDoubleSlashes(url: string) { + return url.replace(/([^:]\/)\/+/g, '$1') +}