New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@internetarchive/search-service

Package Overview
Dependencies
Maintainers
12
Versions
158
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@internetarchive/search-service - npm Package Compare versions

Comparing version 0.0.1-alpha.16 to 0.0.1-alpha.17

2

dist/src/search-params.d.ts

@@ -17,3 +17,3 @@ export declare enum SortDirection {

* parameters to an IA-style query string. ie. it converts the `fields` array
* to `fl[]=identifier&fl[]=collection` and `sort` to `sort[]=date+desc&sort[]=downloads+asc`
* to `fl=identifier,collection` and `sort` to `sort=date+desc,downloads+asc`
*/

@@ -20,0 +20,0 @@ export declare class SearchParams {

@@ -21,3 +21,3 @@ export var SortDirection;

* parameters to an IA-style query string. ie. it converts the `fields` array
* to `fl[]=identifier&fl[]=collection` and `sort` to `sort[]=date+desc&sort[]=downloads+asc`
* to `fl=identifier,collection` and `sort` to `sort=date+desc,downloads+asc`
*/

@@ -40,3 +40,2 @@ export class SearchParams {

get asUrlSearchParams() {
var _a, _b;
const params = new URLSearchParams();

@@ -51,8 +50,9 @@ params.append('q', this.query);

}
(_a = this.fields) === null || _a === void 0 ? void 0 : _a.forEach(field => {
params.append('fl[]', field);
});
(_b = this.sort) === null || _b === void 0 ? void 0 : _b.forEach(sort => {
params.append('sort[]', `${sort.asString}`);
});
if (this.fields) {
params.append('fl', this.fields.join(','));
}
if (this.sort) {
const sortStrings = this.sort.map(sort => sort.asString);
params.append('sort', sortStrings.join(','));
}
return params;

@@ -59,0 +59,0 @@ }

@@ -40,3 +40,3 @@ import { expect } from '@open-wc/testing';

const queryAsString = urlSearchParam.toString();
const expected = 'q=title%3Afoo+AND+collection%3Abar&output=json&fl%5B%5D=identifier&fl%5B%5D=foo&fl%5B%5D=bar';
const expected = 'q=title%3Afoo+AND+collection%3Abar&output=json&fl=identifier%2Cfoo%2Cbar';
expect(queryAsString).to.equal(expected);

@@ -57,6 +57,23 @@ });

const queryAsString = urlSearchParam.toString();
const expected = 'q=title%3Afoo+AND+collection%3Abar&output=json&rows=53&page=27&fl%5B%5D=identifier&fl%5B%5D=foo&fl%5B%5D=bar&sort%5B%5D=downloads+desc';
const expected = 'q=title%3Afoo+AND+collection%3Abar&output=json&rows=53&page=27&fl=identifier%2Cfoo%2Cbar&sort=downloads+desc';
expect(queryAsString).to.equal(expected);
});
it('properly generates a URLSearchParam multiple sort params', async () => {
const query = 'title:foo AND collection:bar';
const sort = [
new SortParam('downloads', SortDirection.Desc),
new SortParam('foo', SortDirection.Asc),
];
const params = new SearchParams({
query,
sort,
rows: 53,
page: 27,
});
const urlSearchParam = params.asUrlSearchParams;
const queryAsString = urlSearchParam.toString();
const expected = 'q=title%3Afoo+AND+collection%3Abar&output=json&rows=53&page=27&sort=downloads+desc%2Cfoo+asc';
expect(queryAsString).to.equal(expected);
});
});
//# sourceMappingURL=search-params.test.js.map
{
"name": "@internetarchive/search-service",
"version": "0.0.1-alpha.16",
"version": "0.0.1-alpha.17",
"description": "A search service for the Internet Archive",

@@ -5,0 +5,0 @@ "license": "AGPL-3.0-only",

@@ -26,3 +26,3 @@ export enum SortDirection {

* parameters to an IA-style query string. ie. it converts the `fields` array
* to `fl[]=identifier&fl[]=collection` and `sort` to `sort[]=date+desc&sort[]=downloads+asc`
* to `fl=identifier,collection` and `sort` to `sort=date+desc,downloads+asc`
*/

@@ -69,14 +69,18 @@ export class SearchParams {

}
if (this.page) {
params.append('page', String(this.page));
}
this.fields?.forEach(field => {
params.append('fl[]', field);
});
this.sort?.forEach(sort => {
params.append('sort[]', `${sort.asString}`);
});
if (this.fields) {
params.append('fl', this.fields.join(','));
}
if (this.sort) {
const sortStrings = this.sort.map(sort => sort.asString);
params.append('sort', sortStrings.join(','));
}
return params;
}
}

@@ -47,3 +47,3 @@ import { expect } from '@open-wc/testing';

const expected =
'q=title%3Afoo+AND+collection%3Abar&output=json&fl%5B%5D=identifier&fl%5B%5D=foo&fl%5B%5D=bar';
'q=title%3Afoo+AND+collection%3Abar&output=json&fl=identifier%2Cfoo%2Cbar';
expect(queryAsString).to.equal(expected);

@@ -66,5 +66,24 @@ });

const expected =
'q=title%3Afoo+AND+collection%3Abar&output=json&rows=53&page=27&fl%5B%5D=identifier&fl%5B%5D=foo&fl%5B%5D=bar&sort%5B%5D=downloads+desc';
'q=title%3Afoo+AND+collection%3Abar&output=json&rows=53&page=27&fl=identifier%2Cfoo%2Cbar&sort=downloads+desc';
expect(queryAsString).to.equal(expected);
});
it('properly generates a URLSearchParam multiple sort params', async () => {
const query = 'title:foo AND collection:bar';
const sort = [
new SortParam('downloads', SortDirection.Desc),
new SortParam('foo', SortDirection.Asc),
];
const params = new SearchParams({
query,
sort,
rows: 53,
page: 27,
});
const urlSearchParam = params.asUrlSearchParams;
const queryAsString = urlSearchParam.toString();
const expected =
'q=title%3Afoo+AND+collection%3Abar&output=json&rows=53&page=27&sort=downloads+desc%2Cfoo+asc';
expect(queryAsString).to.equal(expected);
});
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc