Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User session constructor strips the trailing slash of the provided URL #1073

Open
arozniak opened this issue Jan 20, 2023 · 4 comments
Open

Comments

@arozniak
Copy link

Describe the bug

The user session constructor strips the trailing slash of the provided URL.

import {ArcGISIdentityManager} from '@esri/arcgis-rest-request';

  const userSession = new ArcGISIdentityManager({
    portal: portalUrl,
    clientId,
    token,
  });

Since we need a portal URL with a trailing slash at the end (for the Enterprise implementation), we need to add the following hack to the code:

  const session = userSession as any;
  session.portal += '/';

Is this an expected behavior?

cc @sandromartis

Reproduction

see above

Logs

No response

System Info

"@esri/arcgis-rest-request": "^4.0.3"

Additional Information

No response

@patrickarlt
Copy link
Contributor

@arozniak could you provide a reproduction case where this breaks? You can email me internally if you want.

We agreed at the start of the ArcGIS REST JS project to normalize URLs to not contain a trailing / because ti makes concatenation easier.

@aseigo
Copy link

aseigo commented Mar 30, 2023

Here is a minimal test case:

import {  ArcGISIdentityManager  } from '@esri/arcgis-rest-request';
import { createFeatureService } from '@esri/arcgis-rest-feature-service';
import {  getServiceAdminInfo from '@esri/arcgis-rest-feature-service';

const token = ""; //... user provided auth token ..
const clientId = 'arcgisUrban';
const portalUrl = 'https://zrh-urb-arc01.esri.com/portal/'; // or another ArcGIS Enteprise portal URL
const EDIT_CAPABILITIES = 'Query,Create,Update,Delete,Editing';
const AGO_DEFAULT_MAX_RECORD_COUNT = 50_000;

const userSession = new ArcGISIdentityManager({
    portal: portalUrl,
    clientId,
    token,
  });
    
const createFeatureServiceResult = await createFeatureService({
  ...baseQueryOptions,
  item: {
    name: "Some Name",
    capabilities: EDIT_CAPABILITIES,
    hasStaticData: false,
    maxRecordCount: AGO_DEFAULT_MAX_RECORD_COUNT,
    spatialReference: { wkid: CoordinateSystem.WebMercator },
  },
  folderId: '/',
});

// it fails on this call
const { adminServiceInfo } = await getServiceAdminInfo(createBaseFeatureServiceResult.serviceurl, userSession);

To make the above work, this must be added to modify the userSession object

  const session = userSession as any;
  session.portal += '/';

@patrickarlt
Copy link
Contributor

@arozniak @aseigo can you send me some user credentials for that Enterprise installation so I can test the reproduction case? Looking at this I don't see anything out of order. We determine the admin URL in getServiceAdminInfo() be doing this:

  const serviceAdminUrl = serviceUrl.replace(
    "/rest/services",
    "/rest/admin/services"
  );

Can you also send me a createBaseFeatureServiceResult.serviceurl for this example?

@aseigo
Copy link

aseigo commented Apr 20, 2023

Done; I've sent the info by email to keep account and other info off of here :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants