diegomvh / angular-odata

Client side OData typescript library for Angular
https://www.npmjs.com/package/angular-odata
MIT License
46 stars 14 forks source link

skiptoken of annotations returns wrong result when it include - (hyphen) #72

Closed sengokyu closed 1 year ago

sengokyu commented 1 year ago

Hello, I working with Microsoft graph api. The api returns @odata.nextlink just like follows

https://graph.microsoft.com/v1.0/users?$skiptoken=RFNwdAoAAQAAAAAAAAAAFAAAAHoO-P8SZhNEp2n7Frw9z3wBAAAAAAAAAAAAAAAAAAAXMS4yLjg0MC4xMTM1NTYuMS40LjIzMzEGAAAAAAABsa3xtNOT90O-DRY2LSZF_AFWAAAAAQIAAAA

The $skipToken query value include hyphen, so ODataAnnotations skiptoken returns wrong result.

sengokyu commented 1 year ago

Here is a test case.

import { VERSION_4_0 } from '../../constants';
import { ODataHelper } from '../../helper';
import { ODataEntitiesAnnotations } from './annotations';

describe('ODataEntitiesAnnotations', () => {
  let instance: ODataEntitiesAnnotations<AirPort>;
  let annots: Map<string, any>;

  describe('version 4.0', () => {
    beforeEach(() => {
      const helper = ODataHelper[VERSION_4_0];
      annots = new Map<string, any>();
      instance = new ODataEntitiesAnnotations<AirPort>(helper, annots);
    });

    it('returns skipToken', () => {
      // Given
      const nextLink =
        'https://graph.microsoft.com/v1.0/users?$skiptoken=RFNwdAoAAQAAAAAAAAAAFAAAAHoO-P3xtNOT90O-DRY2LSZF_AFWAAAAAQIAAAA';
      annots.set('@odata.nextLink', nextLink);

      // When
      const actual = instance.skiptoken;

      // Then
      const expected =
        'RFNwdAoAAQAAAAAAAAAAFAAAAHoO-P3xtNOT90O-DRY2LSZF_AFWAAAAAQIAAAA';
      expect(actual).toBe(expected);
    });
  });
});

interface AirPort {}