(url)
| 13 | } |
| 14 | |
| 15 | export function parseGoogleSpreadsheetURL(url) { |
| 16 | let parts = { |
| 17 | key: null, |
| 18 | worksheet: 0 // not really sure how to use this to get the feed for that sheet, so this is not ready except for first sheet right now |
| 19 | } |
| 20 | // key as url parameter (old-fashioned) |
| 21 | var key_pat = /\bkey=([-_A-Za-z0-9]+)&?/i; |
| 22 | // https://docs.google.com/spreadsheets/d/e/2PACX-1vTwrxBim-ruoMlLP9CnZIevWdP8rIatkV7XjNGXRSaMI94sNd-VbRF--W7A2kj6wfZhKUHWv1ur0Tb3/pubhtml |
| 23 | var v2_url_pat = /docs.google.com\/spreadsheets.*?\/d\/e\/([^\/]+)\/.+/; // Google prefers pubhtml links with this format |
| 24 | var url_pat = /docs.google.com\/spreadsheets(.*?)\/d\//; // fixing issue of URLs with u/0/d |
| 25 | |
| 26 | if (url.match(key_pat)) { |
| 27 | parts.key = url.match(key_pat)[1]; |
| 28 | // can we get a worksheet from this form? |
| 29 | } else if (url.match(v2_url_pat)) { |
| 30 | let v2_key = url.match(v2_url_pat)[1] |
| 31 | parts.key = `v2:${v2_key}` |
| 32 | // to do: get worksheet from this form? |
| 33 | } else if (url.match(url_pat)) { |
| 34 | var pos = url.search(url_pat) + url.match(url_pat)[0].length; |
| 35 | var tail = url.substr(pos); |
| 36 | parts.key = tail.split('/')[0] |
| 37 | if (url.match(/\?gid=(\d+)/)) { |
| 38 | parts.worksheet = url.match(/\?gid=(\d+)/)[1]; |
| 39 | } |
| 40 | } else if (url.match(/^\b(v2:)?[-_A-Za-z0-9]+$/)) { |
| 41 | parts.key = url; |
| 42 | } |
| 43 | |
| 44 | if (parts.key) { |
| 45 | return parts; |
| 46 | } else { |
| 47 | return null; |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | |
| 52 | function interpretBackground(bkgd) { |
no outgoing calls
no test coverage detected