Always Add AMP to URL
This is the basis for a bookmarklet I am writing to take me to the amp testing page for the current url. Original fiddle https://stackoverflow.com/questions/11531363/javascript-jquery-add-trailing-slash-to-url-if-not-present
by Brian Layman
JavaScript
var urls = [
'http://example.com',
'http://example.com?foo=bar',
'http://example.com/',
'http://example.com/?foo=bar',
'http://example.com/qwe',
'http://example.com/qwe?foo=bar',
'http://example.com/qwe/',
'http://example.com/qwe/?foo=bar',
'http://example.com/amp',
'http://example.com/amp?foo=bar',
'http://example.com/amp/',
'http://example.com/amp/?foo=bar',
'http://example.com/qwe/amp',
'http://example.com/qwe/amp?foo=bar',
'http://example.com/qwe/amp/',
'http://example.com/qwe/amp/?foo=bar',
];
for(var i=0; i<urls.length; i++) {
$('body').append(urls[i].replace(/\/?(\?|#|$)/, '/amp/$1').replace(/\/amp\/amp/, '/amp') + '<br />');
}