-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from depatchedmode/v0.8.0
v0.8.0 - migration to frames.js #23
- Loading branch information
Showing
11 changed files
with
87 additions
and
99 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,23 @@ | ||
const DEFAULT_FRAME = 'poster'; | ||
import frames from '../src/frames'; | ||
import { isFrameStolen } from './antitheft'; | ||
|
||
export default (name, buttonId, frames) => { | ||
export default async (frameMessage) => { | ||
const frameIsStolen = await isFrameStolen(frameMessage); | ||
let targetFrameName = DEFAULT_FRAME; | ||
let redirectUrl = null; | ||
if (name && buttonId) { | ||
const originFrame = frames[name]; | ||
const button = originFrame.buttons[buttonId-1]; | ||
let redirectURL = null; | ||
console.log('getTargetFrame:frameIsStolen', frameIsStolen); | ||
if (frameIsStolen) { | ||
targetFrameName = 'stolen'; | ||
} else if (frameMessage.buttonIndex) { | ||
const originFrame = frames[frameMessage.from]; | ||
const button = originFrame.buttons[frameMessage.buttonIndex-1]; | ||
targetFrameName = button.goTo; | ||
redirectUrl = button.url; | ||
} | ||
const targetFrameSrc = frames[targetFrameName]; | ||
redirectURL = button.url; | ||
} | ||
|
||
return { | ||
targetFrameSrc, | ||
targetFrameName, | ||
redirectUrl | ||
}; | ||
targetFrame: frames[targetFrameName], | ||
redirectURL | ||
} | ||
} |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { JSDOM } from 'jsdom'; | ||
import DOMPurify from 'dompurify'; | ||
|
||
export default (text) => { | ||
try { | ||
const window = new JSDOM('').window; | ||
const purify = DOMPurify(window); | ||
return purify.sanitize(text); | ||
} catch { | ||
throw new Error(`That ain't no string mfr`) | ||
} | ||
} |
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 was deleted.
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