Skip to content

Commit

Permalink
Add hostname option (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
apetho authored Nov 1, 2023
1 parent ffd5acb commit 8dd370b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
7 changes: 7 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ declare namespace electronServe {
*/
scheme?: string;

/**
Custom hostname.
@default '-'
*/
hostname?: string;

/**
Whether [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) should be enabled.
Useful for testing purposes.
Expand Down
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ const getPath = async path_ => {
module.exports = options => {
options = Object.assign({
isCorsEnabled: true,
scheme: 'app'
scheme: 'app',
hostname: '-'
}, options);

if (!options.directory) {
Expand Down Expand Up @@ -72,6 +73,6 @@ module.exports = options => {
});

return async window_ => {
await window_.loadURL(`${options.scheme}://-`);
await window_.loadURL(`${options.scheme}://${options.hostname}`);
};
};
7 changes: 7 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ Default: `'app'`

Custom scheme. For example, `foo` results in your `directory` being available at `foo://-`.

##### hostname

Type: `string`\
Default: `'-'`

Custom hostname.

##### isCorsEnabled

Type: `boolean`\
Expand Down

0 comments on commit 8dd370b

Please sign in to comment.