fix(gerrit): return HTML titles in more cases
At present, we don't return HTML titles if there's a trailing slash, or a patchset. Instead, just consume the / and anything after it. This also fixes /123, because this is HTTP redirected to the full path *with a trailing slash* which otherwise wouldn't get the title injected. Change-Id: Idfd0e67752880a37dce0b400a3c1cfc53fac2912 Reviewed-on: https://cl.tvl.fyi/c/depot/+/859 Reviewed-by: BuildkiteCI Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
This commit is contained in:
parent
26bb34823d
commit
3f6518ce99
5 changed files with 64 additions and 11 deletions
|
|
@ -1,32 +0,0 @@
|
|||
diff --git a/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.js b/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.js
|
||||
index 1a0bbd9f50..d8d2fa643b 100644
|
||||
--- a/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.js
|
||||
+++ b/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.js
|
||||
@@ -102,6 +102,10 @@ const LANGUAGE_MAP = {
|
||||
};
|
||||
const ASYNC_DELAY = 10;
|
||||
|
||||
+const FILENAME_OVERRIDES = {
|
||||
+ 'rules.pl': 'prolog',
|
||||
+};
|
||||
+
|
||||
const CLASS_WHITELIST = {
|
||||
'gr-diff gr-syntax gr-syntax-attr': true,
|
||||
'gr-diff gr-syntax gr-syntax-attribute': true,
|
||||
@@ -233,10 +237,16 @@ class GrSyntaxLayer extends GestureEventListeners(
|
||||
}
|
||||
}
|
||||
|
||||
+ _basename(filename) {
|
||||
+ const pieces = filename.split(/\//);
|
||||
+ return pieces[pieces.length-1];
|
||||
+ }
|
||||
+
|
||||
_getLanguage(diffFileMetaInfo) {
|
||||
// The Gerrit API provides only content-type, but for other users of
|
||||
// gr-diff it may be more convenient to specify the language directly.
|
||||
return diffFileMetaInfo.language ||
|
||||
+ FILENAME_OVERRIDES[this._basename(diffFileMetaInfo.name)] ||
|
||||
LANGUAGE_MAP[diffFileMetaInfo.content_type];
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue