|
1 | 1 | /////////////////////////////////////////////////////////////////////////// |
2 | | -// Copyright © 2014 - 2018 Esri. All Rights Reserved. |
| 2 | +// Copyright © Esri. All Rights Reserved. |
3 | 3 | // |
4 | 4 | // Licensed under the Apache License Version 2.0 (the "License"); |
5 | 5 | // you may not use this file except in compliance with the License. |
|
77 | 77 |
|
78 | 78 | //This version number will be appended to URL to avoid cache. |
79 | 79 | //The reason we do not use wabVersion is to avoid force user to change wabVersion when they are customizing app. |
80 | | - deployVersion = '2.9'; |
| 80 | + deployVersion = '2.12'; |
81 | 81 |
|
82 | 82 | // console.time('before map'); |
83 | 83 |
|
|
90 | 90 | (function(global){ |
91 | 91 | //init API URL |
92 | 92 | var queryObject = getQueryObject(); |
93 | | - var apiVersion = '4.8'; |
| 93 | + var apiVersion = '4.11'; |
94 | 94 | ////////uncomment the following line when downloading the app |
95 | 95 |
|
96 | | - apiUrl = 'https://js.arcgis.com/4.8'; |
| 96 | + apiUrl = 'https://js.arcgis.com/4.11'; |
97 | 97 |
|
98 | 98 | ////////////////////////////////////////////////////////////// |
99 | 99 | allCookies = getAllCookies(); |
100 | 100 | window.appInfo = {isRunInPortal: !isXT}; |
| 101 | + |
| 102 | + if (queryObject.apiurl3d) { |
| 103 | + if(!checkApiUrl(queryObject.apiurl3d)){ |
| 104 | + console.error('?apiurl must point to an ULR that is in the app or in esri.com/arcgis.com domain.'); |
| 105 | + return; |
| 106 | + } |
| 107 | + apiUrl = queryObject.apiurl3d; |
| 108 | + } |
101 | 109 | if (!apiUrl) { |
102 | | - if (queryObject.apiurl3d) { |
103 | | - apiUrl = queryObject.apiurl3d; |
104 | | - } else if (isXT) { |
| 110 | + if (isXT) { |
105 | 111 | apiUrl = 'https://js.arcgis.com/' + apiVersion; |
106 | 112 | } else { |
107 | 113 | var portalUrl = getPortalUrlFromLocation(); |
|
141 | 147 | return cookies; |
142 | 148 | } |
143 | 149 |
|
| 150 | + function checkApiUrl(url){ |
| 151 | + if(/^\/\//.test(url) || /^https?:\/\//.test(url)){ |
| 152 | + return /(?:[\w\-\_]+\.)+(?:esri|arcgis)\.com/.test(url); //api url must be in esri.com or arcgis.com |
| 153 | + }else{ |
| 154 | + return true; |
| 155 | + } |
| 156 | + } |
| 157 | + |
144 | 158 | function getPortalUrlFromLocation(){ |
145 | 159 | var portalUrl = getPortalServerFromLocation() + getDeployContextFromLocation(); |
146 | 160 | return portalUrl; |
|
152 | 166 | } |
153 | 167 |
|
154 | 168 | function getDeployContextFromLocation (){ |
155 | | - var keyIndex = window.location.href.indexOf("/home"); |
| 169 | + var keyIndex = window.location.href.indexOf("/home/"); |
156 | 170 | if(keyIndex < 0){ |
157 | | - keyIndex = window.location.href.indexOf("/apps"); |
| 171 | + keyIndex = window.location.href.indexOf("/apps/"); |
158 | 172 | } |
159 | 173 | var context = window.location.href.substring(window.location.href.indexOf( |
160 | 174 | window.location.host) + window.location.host.length + 1, keyIndex); |
|
0 commit comments