-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Invalid URL Fix: Decoding manually for some reserved characters (#1682)
* fix: decoding manually for reserved characters * chore: typo fix * test: test fix on percy.test.js and snapshot.test.js * chore: revert file * test: test fix * revert: Removing modifySnapshotUrl from snaphshot config * test: added 1 more test for multiple reserved character * feat: preserving reserved character from encoding * test: test fix + only show warning for network logs if snapshot.url != request.url * chore: null check for passing tests * test: test coverage * test: test fix * chore: remvoving some excessive comments
- Loading branch information
1 parent
2a7eb67
commit d6f9fc2
Showing
7 changed files
with
333 additions
and
3 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
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
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
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,48 @@ | ||
import { decodeAndEncodeURLWithLogging } from '../src/utils.js'; | ||
import { logger } from './helpers/index.js'; | ||
import percyLogger from '@percy/logger'; | ||
|
||
describe('utils', () => { | ||
let log; | ||
beforeEach(async () => { | ||
log = percyLogger(); | ||
logger.reset(true); | ||
await logger.mock({ level: 'debug' }); | ||
}); | ||
|
||
describe('decodeAndEncodeURLWithLogging', () => { | ||
it('does not warn invalid url when options params is null', async () => { | ||
decodeAndEncodeURLWithLogging('https://abc.com/test%abc', log); | ||
expect(logger.stderr).toEqual([]); | ||
}); | ||
|
||
it('does not warn invalid url when shouldLogWarning = false', async () => { | ||
decodeAndEncodeURLWithLogging('https://abc.com/test%abc', log, | ||
{ | ||
shouldLogWarning: false | ||
}); | ||
|
||
expect(logger.stderr).toEqual([]); | ||
}); | ||
|
||
it('returns modified url', async () => { | ||
const url = decodeAndEncodeURLWithLogging('https://abc.com/test[ab]c', log, | ||
{ | ||
shouldLogWarning: false | ||
}); | ||
expect(logger.stderr).toEqual([]); | ||
expect(url).toEqual('https://abc.com/test%5Bab%5Dc'); | ||
}); | ||
|
||
it('warns if invalid url when shouldLogWarning = true', async () => { | ||
decodeAndEncodeURLWithLogging( | ||
'https://abc.com/test%abc', | ||
log, | ||
{ | ||
shouldLogWarning: true, | ||
warningMessage: 'some Warning Message' | ||
}); | ||
expect(logger.stderr).toEqual(['[percy] some Warning Message']); | ||
}); | ||
}); | ||
}); |