Skip to main content

split_target

Function split_target 

Source
pub fn split_target(
    url: &str,
    current_is_https: bool,
    current_host: &str,
) -> (bool, String, String)
Expand description

取得先の (https か, ホスト, パス) を求める。

https://h/phttp://h/p//h/p(プロトコル相対)・/p(ルート相対)を 扱う。現在のページのスキームとホストを引き継ぐ場面があるので受け取る。

§なぜ共通化するか

この判定は同じ誤りを 4 箇所で繰り返していた//host/pathstarts_with('/') の枝に巻き込み、現在のホスト配下のパスとして 取りに行ってしまう誤りで、js/builtins.rsweb_engine/render.rs で 個別に直された後、fetch_script_text_inner に 4 例目が残っていた (実サイトの //ajax.googleapis.com/.../jquery.min.js が 自ホストの HTML を返し、それを JS として実行して構文エラーになっていた)。 判定を 1 箇所に集めて、5 例目が生まれないようにする。