-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
07f2282
commit ada655b
Showing
4 changed files
with
26 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import platform from 'platform' | ||
|
||
export default function getUserAgentHeader (sdk, application, integration) { | ||
const headerParts = [] | ||
|
||
headerParts.push(application ? `app ${application}` : '') | ||
headerParts.push(integration ? `integration ${integration}` : '') | ||
headerParts.push(`sdk ${sdk}`) | ||
headerParts.push(`platform ${platform.name}/${platform.version}`) | ||
headerParts.push(`os ${platform.os.family}/${platform.os.version || '0.0.0'}`) | ||
return headerParts.filter((item) => item !== '').join('; ') | ||
} |
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,9 @@ | ||
import test from 'blue-tape' | ||
import getUserAgent from '../../lib/get-user-agent' | ||
|
||
test('Parse User agent correctly', (t) => { | ||
t.plan(1) | ||
const headerRegEx = /(app|sdk|platform|integration|os) (\S+\/\d.\d.\d)(-\w+)?/igm | ||
const userAgent = getUserAgent('contentful.js/1.0.0', 'myApplication/1.0.0', 'myIntegration/1.0.0') | ||
t.equal(userAgent.match(headerRegEx).length, 5) | ||
}) |
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 |
---|---|---|
|
@@ -2850,6 +2850,10 @@ pkg-dir@^1.0.0: | |
dependencies: | ||
find-up "^1.0.0" | ||
|
||
[email protected]: | ||
version "1.3.3" | ||
resolved "https://registry.yarnpkg.com/platform/-/platform-1.3.3.tgz#646c77011899870b6a0903e75e997e8e51da7461" | ||
|
||
pluralize@^1.2.1: | ||
version "1.2.1" | ||
resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-1.2.1.tgz#d1a21483fd22bb41e58a12fa3421823140897c45" | ||
|