Skip to content

Instantly share code, notes, and snippets.

@masiuchi
Created May 20, 2016 04:00
Show Gist options
  • Save masiuchi/1d084a32bb0a0c53b4d8744378b671b8 to your computer and use it in GitHub Desktop.
Save masiuchi/1d084a32bb0a0c53b4d8744378b671b8 to your computer and use it in GitHub Desktop.
Sinatra application sample for checking JavaScript behaviour.
require 'sinatra'
get '/' do
<<'HTML'
<html>
<head>
<script src="js-alert"></script>
<script src="html-alert"></script>
<script src="js-script"></script>
<script src="html-script"></script>
</head>
<body>
hello
</body>
</html>
HTML
end
get '/js-alert' do
content_type 'application/javascript'
"alert('js-alert');"
end
get '/html-alert' do
"alert('html-alert');"
end
get '/js-script' do
content_type 'application/javascript'
"<script>alert('js-script');</script>"
end
get '/html-script' do
"<script>alert('html-script');</script>"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment