UNPKG

@esri/arcgis-rest-portal

Version:

ArcGIS Online and Enterprise content and user helpers for @esri/arcgis-rest-request

26 lines 1.1 kB
/* Copyright (c) 2017 Environmental Systems Research Institute, Inc. * Apache-2.0 */ import { cleanUrl } from "@esri/arcgis-rest-request"; /** * Helper that returns the appropriate portal url for a given request. `requestOptions.portal` is given * precedence over `authentication.portal`. If neither `portal` nor `authentication` is present, * `www.arcgis.com/sharing/rest` is returned. * * @param requestOptions - Request options that may have authentication manager * @returns Portal url to be used in API requests */ export function getPortalUrl(requestOptions = {}) { // use portal in options if specified if (requestOptions.portal) { return cleanUrl(requestOptions.portal); } // if auth was passed, use that portal if (requestOptions.authentication && typeof requestOptions.authentication !== "string") { // the portal url is already scrubbed in the auth package return requestOptions.authentication.portal; } // default to arcgis.com return "https://www.arcgis.com/sharing/rest"; } //# sourceMappingURL=get-portal-url.js.map