Skip to content

Commit

Permalink
Merge pull request #5 from daltonmenezes/feat/v1.0.4
Browse files Browse the repository at this point in the history
Feat/v1.0.4
  • Loading branch information
daltonmenezes authored Nov 2, 2022
2 parents e5530bb + 90c1e2c commit a1b5be5
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,13 @@ Example:
### Route
It's the [react-router-dom](https://reactrouter.com/en/main/route/route#type-declaration) `<Route />` 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.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
6 changes: 5 additions & 1 deletion src/main/modules/routes/create-url.ts
Original file line number Diff line number Diff line change
@@ -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)
}
1 change: 1 addition & 0 deletions src/shared/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './utils/remove-url-extra-double-slashes'
export * from './utils/to-lower-case-keys'
3 changes: 3 additions & 0 deletions src/shared/utils/remove-url-extra-double-slashes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function removeURLExtraDoubleSlashes(url: string) {
return url.replace(/([^:]\/)\/+/g, '$1')
}

0 comments on commit a1b5be5

Please sign in to comment.