Skip to content

Commit eaa29e7

Browse files
committed
Check if inspection URL is relative
1 parent 7a66b26 commit eaa29e7

File tree

1 file changed

+14
-5
lines changed
  • src/Umbraco.Cms.Integrations.SEO.GoogleSearchConsole.UrlInspectionTool/App_Plugins/UmbracoCms.Integrations/SEO/GoogleSearchConsole/URLInspectionTool/js

1 file changed

+14
-5
lines changed

src/Umbraco.Cms.Integrations.SEO.GoogleSearchConsole.UrlInspectionTool/App_Plugins/UmbracoCms.Integrations/SEO/GoogleSearchConsole/URLInspectionTool/js/url-inspection-tool.controller.js

+14-5
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,28 @@
1717
};
1818

1919
// get oauth configuration
20-
umbracoCmsIntegrationsGoogleSearchConsoleUrlInspectionToolResource.getOAuthConfiguration().then(function(response) {
20+
umbracoCmsIntegrationsGoogleSearchConsoleUrlInspectionToolResource.getOAuthConfiguration().then(function (response) {
2121
vm.oauthConfiguration = response;
2222
});
2323

24-
vm.onConnectClick = function() {
24+
vm.onConnectClick = function () {
2525
vm.authorizationWindow = window.open(vm.oauthConfiguration.authorizationUrl,
2626
"GoogleSearchConsole_Authorize",
2727
"width=900,height=700,modal=yes,alwaysRaised=yes");
2828
}
2929

30-
vm.onRevokeToken = function() {
30+
vm.onRevokeToken = function () {
3131
revokeToken();
3232
}
3333

3434
vm.onInspect = function () {
3535

3636
vm.loading = true;
3737

38+
// check if url is relative
39+
if (isRelativeUrl(vm.inspectionObj.inspectionUrl))
40+
vm.inspectionObj.inspectionUrl = `${vm.inspectionObj.siteUrl}${vm.inspectionObj.inspectionUrl}`;
41+
3842
umbracoCmsIntegrationsGoogleSearchConsoleUrlInspectionToolResource.inspect(vm.inspectionObj.inspectionUrl, vm.inspectionObj.siteUrl, vm.inspectionObj.languageCode)
3943
.then(function (response) {
4044

@@ -58,12 +62,12 @@
5862
});
5963
}
6064

61-
vm.onEdit = function() {
65+
vm.onEdit = function () {
6266
vm.inspectionObj.multipleUrls = false;
6367
vm.inspectionObj.enabled = true;
6468
}
6569

66-
vm.onChangeInspectionUrl = function() {
70+
vm.onChangeInspectionUrl = function () {
6771
vm.inspectionObj.languageCode =
6872
editorState.current.urls.find(p => p.text === vm.inspectionObj.inspectionUrl).culture;
6973
}
@@ -118,6 +122,11 @@
118122
vm.showResults = false;
119123
});
120124
}
125+
126+
function isRelativeUrl(url) {
127+
var regExp = new RegExp('^(?:[a-z]+:)?//', 'i');
128+
return !regExp.test(url);
129+
}
121130
}
122131

123132
angular.module("umbraco")

0 commit comments

Comments
 (0)