Gathering detailed insights and metrics for @jedmao/location
Gathering detailed insights and metrics for @jedmao/location
Gathering detailed insights and metrics for @jedmao/location
Gathering detailed insights and metrics for @jedmao/location
A Location class that implements the Location interface of the Web API.
npm install @jedmao/location
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
8 Stars
213 Commits
2 Forks
2 Watching
12 Branches
3 Contributors
Updated on 16 Aug 2023
Minified
Minified + Gzipped
TypeScript (100%)
Cumulative downloads
Total Downloads
Last day
-6.6%
26,551
Compared to previous day
Last week
1%
132,113
Compared to previous week
Last month
10.8%
553,490
Compared to previous month
Last year
73%
6,066,919
Compared to previous year
21
A LocationMock
class that extends URL
and implements the Location interface of the Web API
. As always, with first-class TypeScript support!
1npm i --save-dev @jedmao/location
1import { LocationMock } from '@jedmao/location' 2 3const loc = new LocationMock('http://foo.com/') 4loc.assign('http://bar.com/') 5loc.replace('http://baz.com/') 6loc.reload()
Because this package extends URL
, many features are provided for free. This means you can do this:
1new LocationMock('http://jed:secret@test:42/foo?bar=baz#qux')
Which returns the following object:
1LocationMock { 2 href: 'http://jed:secret@test:42/foo?bar=baz#qux', 3 origin: 'http://test:42', 4 protocol: 'http:', 5 username: 'jed', 6 password: 'secret', 7 host: 'test:42', 8 hostname: 'test', 9 port: '42', 10 pathname: '/foo', 11 search: '?bar=baz', 12 searchParams: URLSearchParams { 'bar' => 'baz' }, 13 hash: '#qux' }
A common use for this package is to mock the window.location
, which you can do in Jest like so:
1const { location: savedLocation } = window 2 3beforeAll(() => { 4 delete window.location 5}) 6 7beforeEach(() => { 8 window.location = new LocationMock('http://test/') 9}) 10 11afterAll(() => { 12 window.location = savedLocation 13}) 14 15it('assigns /login', () => { 16 const assign = jest 17 .spyOn(window.location, 'assign') 18 .mockImplementationOnce(() => {}) 19 20 window.location.assign('/login') 21 22 expect(assign).toHaveBeenCalledWith('/login') 23})
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
Project has not signed or included provenance with any releases.
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
46 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More@one-ini/wasm
Parse EditorConfig-INI file contents into AST
eclint
Validate or fix code that doesn't adhere to EditorConfig settings or infer settings from existing code.
linez
Parses lines from text, preserving line numbers, offsets and line endings.
@jedmao/redux-mock-store
A mock store for testing your redux async action creators and middleware