forked from VOICEVOX/voicevox
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/2039_sequencer_selectable_edit_mode
- Loading branch information
Showing
5 changed files
with
48 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** エンジンのURLを構成するパラメータ */ | ||
export type EngineUrlParams = { | ||
protocol: string; // `http:`など | ||
hostname: string; // `example.com`など | ||
port: string; // `50021`など。空文字列もありえる。 | ||
pathname: string; // `/engine`など。空文字列もありえる。 | ||
}; | ||
|
||
/** | ||
* URLを構成するパラメータから、VOICEVOXエディタが初期から想定しているURL文字列を組み立てる。 | ||
* pathnameが空文字の場合は末尾にスラッシュを付与しない、などがビルトインのURLクラスと異なる。 | ||
*/ | ||
export function createEngineUrl(params: EngineUrlParams) { | ||
const { protocol, hostname, port, pathname } = params; | ||
const url = new URL(`${protocol}//${hostname}`); // NOTE: URLを正規化する | ||
url.port = port; | ||
return `${url.origin}${pathname}`; // NOTE: URLインターフェースは"pathname"が空文字でも"/"を付けるので手動で結合する。 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters