Skip to content

Instantly share code, notes, and snippets.

@f1h0
Last active April 7, 2016 15:19
Show Gist options
  • Save f1h0/674b8b211a1f9faea9a4 to your computer and use it in GitHub Desktop.
Save f1h0/674b8b211a1f9faea9a4 to your computer and use it in GitHub Desktop.
/*
Функция из URL извлекает pathname
после указываем условия при котором идет и поиск совпадения
lastIndexOf() ищет значние в индексе, выводить на экран все после "/""
*/
function () {
var pagePath = location.pathname;
if (pagePath.indexOf("/search/") === 0) {
var searchString = pagePath.substring(pagePath.lastIndexOf("/") + 1);
return searchString;
}
else {
return "none";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment