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

Three small fixes #17

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SRU client for Node.js and browser
### ES modules
```js
import createSruClient from '@natlibfi/sru-client';
const client = createSruClient({url: 'https://foo.bar'});
const client = createSruClient({serverUrl: 'https://foo.bar'});

client.searchRetrieve('foo')
.on('record', xmlString => processRecord(xmlString))
Expand All @@ -16,7 +16,7 @@ client.searchRetrieve('foo')
### Node
```js
const createSruClient = require('@natlibfi/sru-client').default;
const client = createSruClient({url: 'https://foo.bar'});
const client = createSruClient({serverUrl: 'https://foo.bar'});

client.searchRetrieve('foo')
.on('record', xmlString => processRecord(xmlString))
Expand Down
8 changes: 4 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ export default function ({serverUrl, version, maximumRecords, recordSchema}) {
const doc = new DOMParser().parseFromString(await response.text());

try {
if (Number(doc.getElementsByTagName('zs:numberOfRecords').item(0).textContent) > 0) {
const records = doc.getElementsByTagName('zs:record');
if (Number(doc.getElementsByTagNameNS('http://www.loc.gov/zing/srw/', 'numberOfRecords').item(0).textContent) > 0) {
const records = doc.getElementsByTagNameNS('http://www.loc.gov/zing/srw/', 'record');

for (let i = 0; i < records.length; i++) {
const record = records.item(i);
Expand All @@ -86,8 +86,8 @@ export default function ({serverUrl, version, maximumRecords, recordSchema}) {
}
}

if (doc.getElementsByTagName('zs:nextRecordPosition').length > 0) {
pump(Number(doc.getElementsByTagName('zs:nextRecordPosition').textContent));
if (doc.getElementsByTagNameNS('http://www.loc.gov/zing/srw/', 'nextRecordPosition').length > 0) {
pump(Number(doc.getElementsByTagNameNS('http://www.loc.gov/zing/srw/', 'nextRecordPosition').item(0).textContent));
} else {
Emitter.emit('end');
}
Expand Down