parse-ft-spreadsheet-key
v1.0.3
Published
Helper function for FT IG projects
Downloads
4
Readme
parse-ft-spreadsheet-key
Simple function to parse the spreadsheet key out from an FT Google Sheets URL or Bertha URL.
install
front-end
$ bower install --save parse-ft-spreadsheet-key
<script src="bower_components/parse-ft-spreadsheet-key/index.js"></script>
The function will be available as IG.parseSpreadsheetKey(str)
.
node.js
$ npm install --save-dev parse-ft-spreadsheet-key
var parseSpreadsheetKey = require('parse-ft-spreadsheet-key');
usage
var key = parseSpreadsheetKey('https://docs.google.com/a/ft.com/spreadsheets/d/0Ajt08GcPGJRbdFJUZWZfZ6M1V0xDaTFBckJnNENC8Gc/edit#gid=0');
// key === '0Ajt08GcPGJRbdFJUZWZfZ6M1V0xDaTFBckJnNENC8Gc'
Notes:
- takes valid Bertha URL or Google Spreadsheets URL
- if you pass a plain key on its own, it will return it untouched
- throws an error if something invalid is found, unless you pass
true
as a second argument (silent
), in which case it just returns null