Skip to content

Commit

Permalink
Omit blog id in URL if DEFAULT_BLOG_ID is set. fc2blog#239
Browse files Browse the repository at this point in the history
  • Loading branch information
uzulla committed Mar 20, 2021
1 parent 85ebaf6 commit 0844bf4
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions app/src/Model/BlogsModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -653,11 +653,17 @@ static public function getEntryFullUrlByBlogIdAndEntryId(string $blog_id, string
$schema = static::getSchemaByBlogId($blog_id);
$domain = Config::get("DOMAIN");
$port = ($schema === "https:") ? Config::get("HTTPS_PORT_STR") : Config::get("HTTP_PORT_STR");
return $schema . "//" . $domain . $port . "/" . $blog_id . "/blog-entry-" . (int)$entry_id . ".html";
// default blog ならば blog_idは省略する
if ($blog_id !== Config::get('DEFAULT_BLOG_ID')) {
$blog_id_path = '/' . $blog_id ;
}else{
$blog_id_path = "";
}
return $schema . "//" . $domain . $port . $blog_id_path . "/blog-entry-" . (int)$entry_id . ".html";
}

/**
* Blog Idをキーとして、そのブログの`http(s)://FQDN(:port)/(blog_id)/`を生成する
* Blog Idをキーとして、そのブログの`http(s)?://FQDN(:port)/(blog_id)?/`を生成する
* @param string $blog_id
* @param ?string $domain 省略時、\Fc2blog\Config::get("DOMAIN")
* @return string
Expand All @@ -668,8 +674,14 @@ static public function getFullUrlByBlogId(string $blog_id, ?string $domain = nul
if (is_null($domain)) {
$domain = Config::get("DOMAIN");
}
// default blog ならば blog_idは省略する
if ($blog_id !== Config::get('DEFAULT_BLOG_ID')) {
$blog_id_path = '/' . $blog_id ;
}else{
$blog_id_path = "";
}
$port = ($schema === "https:") ? Config::get("HTTPS_PORT_STR") : Config::get("HTTP_PORT_STR");
return $schema . "//" . $domain . $port . "/" . $blog_id . "/";
return $schema . "//" . $domain . $port . $blog_id_path . "/";
}

/**
Expand Down

0 comments on commit 0844bf4

Please sign in to comment.