]> source.dussan.org Git - sonarqube.git/commitdiff
SONARCLOUD-81 Change canonical url to be absolute (#421)
authorStas Vilchik <stas.vilchik@sonarsource.com>
Thu, 21 Jun 2018 14:38:13 +0000 (16:38 +0200)
committerSonarTech <sonartech@sonarsource.com>
Thu, 21 Jun 2018 18:21:31 +0000 (20:21 +0200)
server/sonar-web/src/main/js/apps/overview/components/OverviewApp.tsx
server/sonar-web/src/main/js/helpers/urls.ts

index 8ef2e87550916df97d1c4e44a2e28a5e7b24ca38..68a7d1bbb1db3cd62db22e2c60daf6e420b028b3 100644 (file)
@@ -48,7 +48,8 @@ import { fetchMetrics } from '../../../store/rootActions';
 import { getMetrics } from '../../../store/rootReducer';
 import { BranchLike, Component, Metric } from '../../../app/types';
 import { translate } from '../../../helpers/l10n';
-import { getPathUrlAsString, getProjectUrl } from '../../../helpers/urls';
+import { getProjectUrl, getSonarCloudUrlAsString } from '../../../helpers/urls';
+import { isSonarCloud } from '../../../helpers/system';
 import '../styles.css';
 
 interface OwnProps {
@@ -239,9 +240,12 @@ export class OverviewApp extends React.PureComponent<Props, State> {
       <div className="page page-limited">
         <div className="overview page-with-sidebar">
           <Suggestions suggestions="overview" />
-          <Helmet>
-            <link href={getPathUrlAsString(getProjectUrl(component.key))} rel="canonical" />
-          </Helmet>
+
+          {isSonarCloud() && (
+            <Helmet>
+              <link href={getSonarCloudUrlAsString(getProjectUrl(component.key))} rel="canonical" />
+            </Helmet>
+          )}
 
           {this.renderMain()}
 
index a04d8376536fb49e5fcf6bbef17fd26913640c24..93e531c52df70c4449455225b586006e052c0fb8 100644 (file)
@@ -49,6 +49,10 @@ export function getPathUrlAsString(path: Location): string {
   return `${getBaseUrl()}${path.pathname}?${stringify(omitBy(path.query, isNil))}`;
 }
 
+export function getSonarCloudUrlAsString(location: Location) {
+  return 'https://sonarcloud.io' + getPathUrlAsString(location);
+}
+
 export function getProjectUrl(project: string): Location {
   return { pathname: '/dashboard', query: { id: project } };
 }