This repository has been archived by the owner on Nov 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: rm-122 format useragent in simple terms
- Loading branch information
Showing
19 changed files
with
3,939 additions
and
18,685 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// eslint-disable-next-line no-unused-vars | ||
const React = require('react'); | ||
|
||
module.exports.default = 'SvgrURL'; | ||
module.exports.ReactComponent = 'div'; |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { getHeaderValue, getFormattedUserAgent } from '../utils'; | ||
|
||
describe('API Logs Utils', () => { | ||
describe('getHeaderValue', () => { | ||
let headers; | ||
|
||
beforeEach(() => { | ||
headers = [ | ||
{ name: 'Content-Type', value: 'image/jpeg' }, | ||
{ name: 'User-Agent', value: 'Mozilla' }, | ||
]; | ||
}); | ||
|
||
it('returns the value of a specified http header', () => { | ||
expect(getHeaderValue(headers, 'User-Agent')).toBe('Mozilla'); | ||
}); | ||
|
||
it('normalizes case of header key', () => { | ||
expect(getHeaderValue(headers, 'content-type')).toBe('image/jpeg'); | ||
}); | ||
|
||
it('returns null if the header is not present', () => { | ||
expect(getHeaderValue(headers, 'not-here')).toBeNull(); | ||
}); | ||
}); | ||
|
||
describe('getFormattedUserAgent', () => { | ||
it('outputs an empty string when fed a falsy value user agent', () => { | ||
expect(getFormattedUserAgent('')).toBe(''); | ||
expect(getFormattedUserAgent(undefined)).toBe(''); | ||
expect(getFormattedUserAgent(null)).toBe(''); | ||
}); | ||
|
||
it('trims whitespace', () => { | ||
expect(getFormattedUserAgent(' ')).toBe(''); | ||
expect(getFormattedUserAgent(' a ')).toBe('a'); | ||
}); | ||
|
||
it('handles readme api explorer', () => { | ||
expect(getFormattedUserAgent('ReadMe-API-Explorer')).toBe('ReadMe API Explorer'); | ||
}); | ||
|
||
it('handles node-fetch', () => { | ||
expect(getFormattedUserAgent('node-fetch/x.x.x')).toBe('node'); | ||
}); | ||
|
||
it('handles python-request', () => { | ||
expect(getFormattedUserAgent('python-request/x.x.x')).toBe('python'); | ||
}); | ||
|
||
it('leaves an unknown user agent untouched', () => { | ||
expect(getFormattedUserAgent('foo-bar/baz')).toBe('foo-bar/baz'); | ||
}); | ||
}); | ||
}); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.