forked from chanind/hanzi-writer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: escaping the URL passed to clip-path to handle parentheses (chan…
…ind#217) Fixing a bug where if the current page has parentheses in the URL, it would cause hanzi-writer to break. Thanks @ cqiangcode for finding this!
- Loading branch information
Showing
5 changed files
with
49 additions
and
4 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,20 @@ | ||
/** | ||
* Hack to allow us to modify jsdom from within tests | ||
* from https://github.com/facebook/jest/issues/5124#issuecomment-352749005 | ||
* */ | ||
|
||
const JSDOMEnvironment = require('jest-environment-jsdom'); | ||
|
||
module.exports = class JSDOMEnvironmentGlobal extends JSDOMEnvironment { | ||
constructor(config) { | ||
super(config); | ||
|
||
this.global.jsdom = this.dom; | ||
} | ||
|
||
teardown() { | ||
this.global.jsdom = null; | ||
|
||
return super.teardown(); | ||
} | ||
}; |
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,24 @@ | ||
import { urlIdRef } from '../svgUtils'; | ||
|
||
describe('urlIdRef', () => { | ||
it('prepends the ID with the current window location', () => { | ||
(global as any).jsdom.reconfigure({ | ||
url: 'https://test.com', | ||
}); | ||
expect(urlIdRef('123-blah')).toEqual('url("https://test.com/#123-blah")'); | ||
}); | ||
|
||
it('escapes " characters in the URL', () => { | ||
(global as any).jsdom.reconfigure({ | ||
url: 'https://test-"(ok).com', | ||
}); | ||
expect(urlIdRef('123-blah')).toEqual('url("https://test-%22(ok).com/#123-blah")'); | ||
}); | ||
|
||
it('strips everything after # in the URL', () => { | ||
(global as any).jsdom.reconfigure({ | ||
url: 'https://test.com/path#existing-hash', | ||
}); | ||
expect(urlIdRef('123-blah')).toEqual('url("https://test.com/path#123-blah")'); | ||
}); | ||
}); |
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