Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hostname option #35

Merged
merged 4 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading