Skip to content

Commit

Permalink
feat: allow message.getTypeUrl provide custom tyepUrlPrefix
Browse files Browse the repository at this point in the history
  • Loading branch information
kairlec committed Jul 7, 2022
1 parent a1d6029 commit 597ddc2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cli/targets/static.js
Original file line number Diff line number Diff line change
Expand Up @@ -597,11 +597,17 @@ function buildType(ref, type) {
"@function getTypeUrl",
"@memberof " + exportName(type),
"@static",
"@param {string|undefined} [typeUrlPrefix] your custom typeUrlPrefix(default \"type.googleapis.com\")",
"@returns {string} The default type url"
]);
push(escapeName(type.name) + ".getTypeUrl = function getTypeUrl() {");
push(escapeName(type.name) + ".getTypeUrl = function getTypeUrl(typeUrlPrefix) {");
++indent;
push("return \"type.googleapis.com/" + exportName(type) + "\";");
push("if (typeUrlPrefix === undefined) {");
++indent;
push("typeUrlPrefix = \"type.googleapis.com\";");
--indent;
push("}");
push("return typeUrlPrefix + \"/" + exportName(type) + "\";");
--indent;
push("};");
}
Expand Down

0 comments on commit 597ddc2

Please sign in to comment.