-
Notifications
You must be signed in to change notification settings - Fork 427
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: campionfellin <campionfellin@gmail.com>
- Loading branch information
1 parent
257fdde
commit da038b4
Showing
7 changed files
with
66 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { | ||
SCRIPT_ID_LENGTH, | ||
} from './apis'; | ||
|
||
/** | ||
* Extracts scriptId from URL if given in URL form. | ||
* @param scriptId {string} either a scriptId or URL containing the scriptId | ||
* @example | ||
* extractScriptId( | ||
* 'https://script.google.com/a/DOMAIN/d/1Ng7bNZ1K95wNi2H7IUwZzM68FL6ffxQhyc_ByV42zpS6qAFX8pFsWu2I/edit' | ||
* ) | ||
* returns '1Ng7bNZ1K95wNi2H7IUwZzM68FL6ffxQhyc_ByV42zpS6qAFX8pFsWu2I' | ||
* @example | ||
* extractScriptId('1Ng7bNZ1K95wNi2H7IUwZzM68FL6ffxQhyc_ByV42zpS6qAFX8pFsWu2I') | ||
* returns '1Ng7bNZ1K95wNi2H7IUwZzM68FL6ffxQhyc_ByV42zpS6qAFX8pFsWu2I' | ||
*/ | ||
export const extractScriptId = (scriptId: string) => { | ||
if (scriptId.length !== SCRIPT_ID_LENGTH) { | ||
const ids = scriptId.split('/').filter(s => { | ||
return s.length === SCRIPT_ID_LENGTH; | ||
}); | ||
if (ids.length) { | ||
scriptId = ids[0]; | ||
} | ||
} | ||
return scriptId; | ||
}; | ||
|
||
// Helpers to get Apps Script project URLs | ||
export const URL = { | ||
APIS: (projectId: string) => `https://console.developers.google.com/apis/dashboard?project=${projectId}`, | ||
CREDS: (projectId: string) => `https://console.developers.google.com/apis/credentials?project=${projectId}`, | ||
LOGS: (projectId: string) => | ||
`https://console.cloud.google.com/logs/viewer?project=${projectId}&resource=app_script_function`, | ||
SCRIPT_API_USER: 'https://script.google.com/home/usersettings', | ||
// It is too expensive to get the script URL from the Drive API. (Async/not offline) | ||
SCRIPT: (scriptId: string) => `https://script.google.com/d/${scriptId}/edit`, | ||
DRIVE: (driveId: string) => `https://drive.google.com/open?id=${driveId}`, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters